diff options
author | Damien Miller <djm@mindrot.org> | 2008-06-15 10:55:34 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2008-06-15 10:55:34 +1000 |
commit | 8b7ab960df02da128c56283ce14b78227ac2d200 (patch) | |
tree | 7ba374e17f85d4e626732d9a87b56ee17527d27b | |
parent | 30fd49e606169c57fef2be66594e24991b2fb747 (diff) |
- (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction
replacement code; patch from ighighi AT gmail.com in bz#1240;
ok dtucker
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | openbsd-compat/sigact.c | 50 |
2 files changed, 45 insertions, 12 deletions
@@ -1,3 +1,8 @@ +20080614 + - (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction + replacement code; patch from ighighi AT gmail.com in bz#1240; + ok dtucker + 20080613 - (dtucker) OpenBSD CVS Sync - deraadt@cvs.openbsd.org 2008/06/13 09:44:36 @@ -4364,4 +4369,4 @@ OpenServer 6 and add osr5bigcrypt support so when someone migrates passwords between UnixWare and OpenServer they will still work. OK dtucker@ -$Id: ChangeLog,v 1.5010 2008/06/13 23:14:46 dtucker Exp $ +$Id: ChangeLog,v 1.5011 2008/06/15 00:55:34 djm Exp $ diff --git a/openbsd-compat/sigact.c b/openbsd-compat/sigact.c index 8b8e4dd2..d67845cf 100644 --- a/openbsd-compat/sigact.c +++ b/openbsd-compat/sigact.c @@ -36,6 +36,7 @@ /* OPENBSD ORIGINAL: lib/libcurses/base/sigaction.c */ #include "includes.h" +#include <errno.h> #include <signal.h> #include "sigact.h" @@ -47,28 +48,39 @@ int sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) { - return sigvec(sig, &(sigact->sv), &(osigact->sv)); + return sigvec(sig, sigact ? &sigact->sv : NULL, + osigact ? &osigact->sv : NULL); } int -sigemptyset (sigset_t * mask) +sigemptyset (sigset_t *mask) { + if (!mask) { + errno = EINVAL; + return -1; + } *mask = 0; return 0; } int -sigprocmask (int mode, sigset_t * mask, sigset_t * omask) +sigprocmask (int mode, sigset_t *mask, sigset_t *omask) { sigset_t current = sigsetmask(0); - if (omask) *omask = current; + if (!mask) { + errno = EINVAL; + return -1; + } - if (mode==SIG_BLOCK) + if (omask) + *omask = current; + + if (mode == SIG_BLOCK) current |= *mask; - else if (mode==SIG_UNBLOCK) + else if (mode == SIG_UNBLOCK) current &= ~*mask; - else if (mode==SIG_SETMASK) + else if (mode == SIG_SETMASK) current = *mask; sigsetmask(current); @@ -76,28 +88,44 @@ sigprocmask (int mode, sigset_t * mask, sigset_t * omask) } int -sigsuspend (sigset_t * mask) +sigsuspend (sigset_t *mask) { + if (!mask) { + errno = EINVAL; + return -1; + } return sigpause(*mask); } int -sigdelset (sigset_t * mask, int sig) +sigdelset (sigset_t *mask, int sig) { + if (!mask) { + errno = EINVAL; + return -1; + } *mask &= ~sigmask(sig); return 0; } int -sigaddset (sigset_t * mask, int sig) +sigaddset (sigset_t *mask, int sig) { + if (!mask) { + errno = EINVAL; + return -1; + } *mask |= sigmask(sig); return 0; } int -sigismember (sigset_t * mask, int sig) +sigismember (sigset_t *mask, int sig) { + if (!mask) { + errno = EINVAL; + return -1; + } return (*mask & sigmask(sig)) != 0; } |