[Bug middle-end/80807] Improve FORTIFY_SOURCE protection for sprintf
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu May 18 08:41:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80807
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Status|UNCONFIRMED |NEW
Last reconfirmed| |2017-05-18
Component|c |middle-end
Known to work| |7.1.0
Ever confirmed|0 |1
Known to fail| |5.4.0, 6.3.0
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
I get with GCC 7:
> gcc-7 t.c -O3 -D_FORTIFY_SOURCE=2 -Wall -S
t.c: In function ‘test’:
t.c:6:29: warning: ‘__builtin___sprintf_chk’ writing a terminating nul past the
end of the destination [-Wformat-overflow=]
sprintf(buf, "%c%c", a, b);
^
In file included from /usr/include/stdio.h:936:0,
from t.c:1:
/usr/include/bits/stdio2.h:33:10: note: ‘__builtin___sprintf_chk’ output 3
bytes into a destination of size 2
return __builtin___sprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
confirmed with GCC 5 and 6.
More information about the Gcc-bugs
mailing list