Some old code went through and found:
char buf[...]; int i = 1, j =2; snprintf(buf, "%d-blah_%d-blah_%N", i, j);
Please note that there are only two parameters passed to vararg, but 3 format lines.
He is typing
1-blah_2-blah_0
It is impossible to find this in any documents. What does% N do?
According to standard documentation (for example, POSIX printf ), it does %Nnot specify anything (therefore, there may be undefined behavior and, of course, undefined behavior in standards).
%N
GNU glibc printf . ( ) register_printf_function %N. , GNU glibc ( , GCC format .).
printf
glibc
format
Microsoft CRT. , %N , .
<VSDIR>/VC/crt/src/output.c, VS2013 :
<VSDIR>/VC/crt/src/output.c
enum CHARTYPE { ... CH_SIZE, /* 'h', 'l', 'L', 'N', 'F', 'w' */ ... };
'N' . , 'F'. (case ST_SIZE) 'N', 'F' 'L' ( !) - -op.
'N'
'F'
case ST_SIZE
'L'
, VS2013 1-blah_2-blah_, 0.
1-blah_2-blah_