Module Name: src
Committed By: christos
Date: Fri Jun 28 17:36:18 UTC 2013
Modified Files:
src/usr.bin/mail: collect.c
Log Message:
prevent re-entry race and crash
To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/mail/collect.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/mail/collect.c
diff -u src/usr.bin/mail/collect.c:1.46 src/usr.bin/mail/collect.c:1.47
--- src/usr.bin/mail/collect.c:1.46 Tue Jun 12 15:03:26 2012
+++ src/usr.bin/mail/collect.c Fri Jun 28 13:36:18 2013
@@ -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 @@ savedeadletter(FILE *fp)
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 @@ coll_int(int signo)
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);
}