Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/mail prevent re-entry race and crash



details:   https://anonhg.NetBSD.org/src/rev/b634b03612db
branches:  trunk
changeset: 787704:b634b03612db
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jun 28 17:36:18 2013 +0000

description:
prevent re-entry race and crash

diffstat:

 usr.bin/mail/collect.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r bd858512915d -r b634b03612db usr.bin/mail/collect.c
--- a/usr.bin/mail/collect.c    Fri Jun 28 17:20:15 2013 +0000
+++ b/usr.bin/mail/collect.c    Fri Jun 28 17:36:18 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: collect.c,v 1.46 2012/06/12 19:03:26 christos Exp $    */
+/*     $NetBSD: collect.c,v 1.47 2013/06/28 17:36:18 christos Exp $    */
 
 /*
  * Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)collect.c  8.2 (Berkeley) 4/19/94";
 #else
-__RCSID("$NetBSD: collect.c,v 1.46 2012/06/12 19:03:26 christos Exp $");
+__RCSID("$NetBSD: collect.c,v 1.47 2013/06/28 17:36:18 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -304,6 +304,7 @@
 static void
 coll_int(int signo)
 {
+       sig_t o = signal(SIGINT, SIG_IGN);
 
        /*
         * the control flow is subtle, because we can be called from ~q.
@@ -318,9 +319,12 @@
                hadintr = 1;
                longjmp(reset_jmpbuf, signo);
        }
-       rewind(collf);
-       if (value(ENAME_NOSAVE) == NULL)
-               savedeadletter(collf);
+       if (collf) {
+               rewind(collf);
+               if (value(ENAME_NOSAVE) == NULL)
+                       savedeadletter(collf);
+       }
+       signal(SIGINT, o);
        longjmp(abort_jmpbuf, signo);
 }
 



Home | Main Index | Thread Index | Old Index