*** protector.dif Wed Jul 30 16:43:21 2003 --- protector.dif.johnc Wed Jul 30 16:43:12 2003 *************** *** 732,738 **** --- gcc/libgcc2.c 2003/04/07 02:02:57 1.1.1.1.4.9 *************** __pure_virtual () *** 4012,4014 **** ! --- 4012,4113 ---- __terminate (); } #endif --- 732,738 ---- --- gcc/libgcc2.c 2003/04/07 02:02:57 1.1.1.1.4.9 *************** __pure_virtual () *** 4012,4014 **** ! --- 4012,4088 ---- __terminate (); } #endif *************** *** 748,762 **** + #endif + + #if defined(HAVE_SYSLOG) - + #include - + #include - + #include - + + #include - + #ifndef _PATH_LOG - + #define _PATH_LOG "/dev/log" + #endif - + #endif + + long __guard[8] = {0,0,0,0,0,0,0,0}; + static void __guard_setup (void) __attribute__ ((constructor)) ; --- 748,755 ---- *************** *** 777,792 **** + } + void __stack_smash_handler (char func[], int damaged ATTRIBUTE_UNUSED) + { ! + #if defined (__GNU_LIBRARY__) ! + extern char * __progname; ! + #endif ! + const char message[] = ": stack smashing attack in function "; ! + int bufsz = 256, len; + char buf[bufsz]; - + #if defined(HAVE_SYSLOG) - + int LogFile; - + struct sockaddr_un SyslogAddr; /* AF_UNIX address of local logger */ - + #endif + #ifdef _POSIX_SOURCE + { + sigset_t mask; --- 770,778 ---- + } + void __stack_smash_handler (char func[], int damaged ATTRIBUTE_UNUSED) + { ! + const char message[] = "stack smashing attack in function "; ! + int bufsz = 256, len = 0; + char buf[bufsz]; + #ifdef _POSIX_SOURCE + { + sigset_t mask; *************** *** 796,823 **** + } + #endif + ! + strcpy(buf, "<2>"); len=3; /* send LOG_CRIT */ ! + #if defined (__GNU_LIBRARY__) ! + strncat(buf, __progname, bufsz-len-1); len = strlen(buf); ! + #endif ! + if (bufsz>len) {strncat(buf, message, bufsz-len-1); len = strlen(buf);} + if (bufsz>len) {strncat(buf, func, bufsz-len-1); len = strlen(buf);} + + /* print error message */ ! + write (STDERR_FILENO, buf+3, len-3); + #if defined(HAVE_SYSLOG) - + if ((LogFile = socket(AF_UNIX, SOCK_DGRAM, 0)) != -1) { + + /* ! + * Send "found" message to the "/dev/log" path + */ ! + SyslogAddr.sun_family = AF_UNIX; ! + (void)strncpy(SyslogAddr.sun_path, _PATH_LOG, ! + sizeof(SyslogAddr.sun_path) - 1); ! + SyslogAddr.sun_path[sizeof(SyslogAddr.sun_path) - 1] = '\0'; ! + sendto(LogFile, buf, len, 0, (struct sockaddr *)&SyslogAddr, ! + sizeof(SyslogAddr)); ! + } + #endif + + #ifdef _POSIX_SOURCE --- 782,798 ---- + } + #endif + ! + strncpy(buf, message, bufsz-len-1); len = strlen(buf); + if (bufsz>len) {strncat(buf, func, bufsz-len-1); len = strlen(buf);} + + /* print error message */ ! + write (STDERR_FILENO, buf, len); + #if defined(HAVE_SYSLOG) + + /* ! + * Send "found" message to syslogd + */ ! + syslog(LOG_AUTH|LOG_CRIT, "%s\0", buf); + #endif + + #ifdef _POSIX_SOURCE *************** *** 1019,1046 **** /* Dump the rtl code if we are dumping rtl. */ if (rtl_dump) ! Index: gcc/config/t-linux ! =================================================================== ! RCS file: /home/cvsroot/gcc/gcc/config/t-linux,v ! retrieving revision 1.1.1.1 ! retrieving revision 1.1.1.1.4.1 ! diff -c -3 -p -r1.1.1.1 -r1.1.1.1.4.1 ! *** gcc/config/t-linux 2001/05/10 08:18:14 1.1.1.1 ! --- gcc/config/t-linux 2001/05/10 10:47:34 1.1.1.1.4.1 ! *************** INSTALL_ASSERT_H = ! *** 7,13 **** ! # Compile crtbeginS.o and crtendS.o with pic. ! CRTSTUFF_T_CFLAGS_S = -fPIC ! # Compile libgcc2.a with pic. ! TARGET_LIBGCC2_CFLAGS = -fPIC ! # Do not build libgcc1. Let gcc generate those functions. The GNU/Linux ! # C library can handle them. ! --- 7,13 ---- ! # Compile crtbeginS.o and crtendS.o with pic. ! CRTSTUFF_T_CFLAGS_S = -fPIC ! # Compile libgcc2.a with pic. ! TARGET_LIBGCC2_CFLAGS = -fPIC -DHAVE_SYSLOG ! ! # Do not build libgcc1. Let gcc generate those functions. The GNU/Linux ! # C library can handle them. --- 994,1026 ---- /* Dump the rtl code if we are dumping rtl. */ if (rtl_dump) ! diff -c gcc/config/sparc/t-sol2 gcc/config/sparc/t-sol2.johnc ! *** gcc/config/sparc/t-sol2 Fri May 23 17:30:26 2003 ! --- gcc/config/sparc/t-sol2.johnc Fri May 23 15:25:29 2003 ! *************** ! *** 27,30 **** ! # routines in crtstuff.c. ! ! CRTSTUFF_T_CFLAGS = -fPIC ! TARGET_LIBGCC2_CFLAGS = -fPIC + --- 27,30 ---- + # routines in crtstuff.c. ! CRTSTUFF_T_CFLAGS = -fPIC ! TARGET_LIBGCC2_CFLAGS = -fPIC -DHAVE_SYSLOG ! ! diff -c gcc/config/i386/t-sol2 gcc/config/i386/t-sol2.johnc ! *** gcc/config/i386/t-sol2 Wed Dec 16 21:04:37 1998 ! --- gcc/config/i386/t-sol2.johnc Wed Jul 30 15:17:34 2003 ! *************** ! *** 37,40 **** ! # .text section. ! ! CRTSTUFF_T_CFLAGS = -fPIC -O2 ! ! TARGET_LIBGCC2_CFLAGS = -fPIC ! --- 37,40 ---- ! # .text section. ! ! CRTSTUFF_T_CFLAGS = -fPIC -O2 ! ! TARGET_LIBGCC2_CFLAGS = -fPIC -DHAVE_SYSLOG !