Add a few missing __*_chk functions
When source code is compiled with -D_FORTIFY_SOURCE on Linux, various functions are sometimes replaced by __*_chk variants (e.g., __strcpy_chk) which can help avoid buffer overflows when the compiler knows the buffer's size during compilation. If we want to run source compiled on Linux with -D_FORTIFY_SOURCE (either deliberately or unintentionally - see issue #111), we need to implement these functions otherwise the program will crash because of a missing symbol. We already implement a bunch of _chk functions, but we are definitely missing some more. This patch implements 6 more _chk functions which are needed to run the "rogue" program (mentioned in issue #111) when compiled with -D_FORTIFY_SOURCE=1. Following the philosophy of our existing *_chk functions, we do not aim for either ultimate performance or iron-clad security for our implementation of these functions. If this becomes important, we should revisit all our *_chk functions. When compiled with -D_FORTIFY_SOURCE=2, rogue still doesn't work, but not because of a missing symbol, but because it fails reading the terminfo file for a yet unknown reason (a patch for that issue will be sent separately). Signed-off-by:Nadav Har'El <nyh@cloudius-systems.com> Signed-off-by:
Pekka Enberg <penberg@cloudius-systems.com>
Showing
- core/poll.cc 8 additions, 0 deletionscore/poll.cc
- libc/stdio/__vfprintf_chk.c 23 additions, 0 deletionslibc/stdio/__vfprintf_chk.c
- libc/string/stpcpy.c 9 additions, 0 deletionslibc/string/stpcpy.c
- libc/string/strcpy.c 8 additions, 0 deletionslibc/string/strcpy.c
- libc/string/strncat.c 15 additions, 0 deletionslibc/string/strncat.c
Loading
Please register or sign in to comment