From a93759f40f1939bfa0439d63016547caab30b094 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 13 Feb 2007 20:37:08 +0000 Subject: "Fix" a horrible signal handler. ckfini() breaks all the rules for signal handlers, calling free() and not being reentrant. This commit fixes to most importamt problem (^C on the "MARK FILESYSTEM CLEAN?" question causes a double free), but actually SIGINT handling should be completely rewritten. ok millert@ deraadt@ --- sbin/fsck_ffs/utilities.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'sbin') diff --git a/sbin/fsck_ffs/utilities.c b/sbin/fsck_ffs/utilities.c index 587cdeeddd6..96fa0637a81 100644 --- a/sbin/fsck_ffs/utilities.c +++ b/sbin/fsck_ffs/utilities.c @@ -1,4 +1,4 @@ -/* $OpenBSD: utilities.c,v 1.30 2006/04/17 19:33:54 deraadt Exp $ */ +/* $OpenBSD: utilities.c,v 1.31 2007/02/13 20:37:07 otto Exp $ */ /* $NetBSD: utilities.c,v 1.18 1996/09/27 22:45:20 christos Exp $ */ /* @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)utilities.c 8.1 (Berkeley) 6/5/93"; #else -static const char rcsid[] = "$OpenBSD: utilities.c,v 1.30 2006/04/17 19:33:54 deraadt Exp $"; +static const char rcsid[] = "$OpenBSD: utilities.c,v 1.31 2007/02/13 20:37:07 otto Exp $"; #endif #endif /* not lint */ @@ -45,6 +45,7 @@ static const char rcsid[] = "$OpenBSD: utilities.c,v 1.30 2006/04/17 19:33:54 de #include #include #include +#include #include #include #include @@ -248,10 +249,16 @@ ckfini(int markclean) { struct bufarea *bp, *nbp; int cnt = 0; + sigset_t oset, nset; + + sigemptyset(&nset); + sigaddset(&nset, SIGINT); + sigprocmask(SIG_BLOCK, &nset, &oset); if (fswritefd < 0) { (void)close(fsreadfd); fsreadfd = -1; + sigprocmask(SIG_SETMASK, &oset, NULL); return; } sblock.fs_flags &= ~FS_FLAGS_UPDATED; /* Force update on next mount */ @@ -295,6 +302,7 @@ ckfini(int markclean) fsreadfd = -1; (void)close(fswritefd); fswritefd = -1; + sigprocmask(SIG_SETMASK, &oset, NULL); } int -- cgit v1.2.3