- bzero(&sa, sizeof(struct sigaction));
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = SIG_DFL;
- sigaction(SIGABRT, &sa, NULL);
+ /* If If a random generator can't be used, the protector switches the guard
+ to the "terminator canary" */
+ ((unsigned char *)__stack_chk_guard)[0] = 0;
+ ((unsigned char *)__stack_chk_guard)[1] = 0;
+ ((unsigned char *)__stack_chk_guard)[2] = '\n';
+ ((unsigned char *)__stack_chk_guard)[3] = 255;
+}
+
+#define STACKOVERFLOW "] stack overflow"
+
+void
+__stack_chk_fail()
+{
+ char n[16]; // bigger than will hold the digits in a pid_t
+ char *np;
+ int pid = getpid();
+ char message[sizeof(n) + sizeof(STACKOVERFLOW)] = "[";
+ char prog[2*MAXCOMLEN+1] = {0};