mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 04:19:21 +08:00
3e8fc7d9f2
The Object Size Checking (-D_FORTIFY_SOURCE=*) functionality provides wrappers around functions suspectible to buffer overflows. While independent from Stack Smashing Protection (-fstack-protector*), they are often used and implemented together. While GCC also provides an implementation in libssp, it is completely broken (CVE-2016-4973, RHBZ#1324759) and seemingly unfixable, as there is no reliable way for a preprocessor macro to trigger a link flag. Therefore, adding this here is necessary to make it work. Note that this does require building gcc with --disable-libssp and gcc_cv_libc_provides_ssp=yes. Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
14 lines
248 B
C
14 lines
248 B
C
#include <signal.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
void
|
|
__attribute__((__noreturn__))
|
|
__chk_fail(void)
|
|
{
|
|
char msg[] = "*** buffer overflow detected ***: terminated\n";
|
|
write (2, msg, strlen (msg));
|
|
raise (SIGABRT);
|
|
_exit (127);
|
|
}
|