Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16681
Modified Files: Tag: impd_0_37 s_inter.c Log Message: being verbose on sys_gui() buffer overflows
Index: s_inter.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/s_inter.c,v retrieving revision 1.1.1.3.2.9.2.4 retrieving revision 1.1.1.3.2.9.2.5 diff -C2 -d -r1.1.1.3.2.9.2.4 -r1.1.1.3.2.9.2.5 *** s_inter.c 2 Apr 2004 05:03:27 -0000 1.1.1.3.2.9.2.4 --- s_inter.c 7 Apr 2004 06:44:50 -0000 1.1.1.3.2.9.2.5 *************** *** 325,329 **** else /* TCP ("streaming") socket protocol */ { - char *semi; int readto = (x->sr_inhead >= x->sr_intail ? INBUFSIZE : x->sr_intail-1); --- 325,328 ---- *************** *** 416,424 **** while (1) { ! //res = send(sys_guisock, s + written, length, 0);
! //fcntl(sys_guisock,F_SETFL,fcntl(sys_guisock,F_GETFL)| O_NONBLOCK); res = send(sys_guisock, s + written, length, 0); ! //fcntl(sys_guisock,F_SETFL,fcntl(sys_guisock,F_GETFL)&~O_NONBLOCK); if (res<0 && errno==EAGAIN) res=0; --- 415,423 ---- while (1) { ! /*res = send(sys_guisock, s + written, length, 0);*/
! /*fcntl(sys_guisock,F_SETFL,fcntl(sys_guisock,F_GETFL)| O_NONBLOCK);*/ res = send(sys_guisock, s + written, length, 0); ! /*fcntl(sys_guisock,F_SETFL,fcntl(sys_guisock,F_GETFL)&~O_NONBLOCK);*/ if (res<0 && errno==EAGAIN) res=0; *************** *** 443,447 **** void sys_vgui(char *fmt, ...) { - int result; unsigned n; char buf[2048]; --- 442,445 ---- *************** *** 450,454 **** n = vsnprintf(buf, sizeof(buf), fmt, ap); if (n>=sizeof(buf)) { ! fprintf(stderr,"sys_vgui: buffer overflow\n"); abort(); } --- 448,453 ---- n = vsnprintf(buf, sizeof(buf), fmt, ap); if (n>=sizeof(buf)) { ! fprintf(stderr,"sys_vgui: buffer overflow (%d in %d)\n",n,sizeof(buf)); ! fprintf(stderr," starts like: %.64s [...]\n",buf); abort(); } *************** *** 481,494 **** { static int trouble = 0; ! if (!trouble) ! { ! trouble = 1; ! fprintf(stderr, "Pd: signal %d\n", n); ! sys_bail(1);
} ! else _exit(1); }
static void sys_alarmhandler(int n) { --- 480,510 ---- { static int trouble = 0; ! if (trouble) _exit(1); ! trouble = 1; ! fprintf(stderr, "Pd: signal %d\n", n); ! sys_bail(1); ! }
+ static void sys_apocalypse(int n) + { + static int trouble = 0; + if (trouble) _exit(1); + trouble = 1; + fprintf(stderr, "Pd: signal %d\n", n); + /* isn't really useful, because it sees only + the signal stack, not the app's stack + #ifdef UNIX + { + pid_t pid = getpid(); + char foo[256]; + sprintf(foo,"rxvt -e gdb --pid=%d `which pd`",pid); + system(foo); } ! #endif ! */ ! sys_bail(1); }
+ static void sys_alarmhandler(int n) { *************** *** 571,576 **** char cmdbuf[4*MAXPDSTRING]; struct sockaddr_in server; - int msgsock; - char buf[15]; int len = sizeof(server); int ntry = 0, portno = FIRSTPORTNUM; --- 587,590 ---- *************** *** 595,601 **** signal(SIGIOT, sys_exithandler); signal(SIGFPE, SIG_IGN); ! /* signal(SIGILL, sys_exithandler); ! signal(SIGBUS, sys_exithandler); ! signal(SIGSEGV, sys_exithandler); */ signal(SIGPIPE, sys_exithandler); signal(SIGALRM, SIG_IGN); --- 609,615 ---- signal(SIGIOT, sys_exithandler); signal(SIGFPE, SIG_IGN); ! signal(SIGILL, sys_apocalypse); ! signal(SIGBUS, sys_apocalypse); ! signal(SIGSEGV, sys_apocalypse); signal(SIGPIPE, sys_exithandler); signal(SIGALRM, SIG_IGN);