This __sprintf_chk() seems to check buffer overflow by examining stack frames.
...
For my research purpose, I wonder if it is possible to disable using __sprintf_chk()?
I believe that's from FORTIFY_SOURCE
. There's quite a few functions guarded like that. I believe the following will work for you:
CFLAGS += -U_FORTIFY_SOURCE
Alternately, you might be able to:
CFLAGS += -D_FORTIFY_SOURCE=0
Related: if I encounter software in the field that disables FORTIFY_SOURCE
, then I file a security defect against it. Its OK to disable ot for Debug and Testing, but its not appropriate for production software.
Related, here's a [potentially incomplete] list of functions that can be protected with FORTIFY_SOURCE
:
- memcpy
- mempcpy
- memmove
- memset
- stpcpy
- strcpy
- strncpy
- strcat
- strncat
- sprintf
- snprintf
- vsprintf
- vsnprintf
- gets
See Difference between gcc -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2.
__sprintf_chk()
so that the linker doesn't pull the from the library? – Pentalpha