void __stack_smash_handler(const char func[], int damaged) { struct sigaction sa; sigset_t mask; char buf[1024]; /* Immediately block all signal handlers from running code */ sigfillset(&mask); sigdelset(&mask, SIGABRT); sigprocmask(SIG_SETMASK, &mask, NULL); /* <10> is LOG_CRIT */ strlcpy(buf, "<10>", sizeof buf); /* Make sure progname does not fill the whole buffer */ strlcat(buf, __progname, sizeof(buf) / 2 ); strlcat(buf, ": stack overflow in function ", sizeof buf); strlcat(buf, func, sizeof buf); sendsyslog(buf, strlen(buf), LOG_CONS); memset(&sa, 0, sizeof(sa)); sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = SIG_DFL; sigaction(SIGABRT, &sa, NULL); thrkill(0, SIGABRT, NULL); _exit(127); }
int raise(int s) { return (thrkill(0, s, NULL)); }