summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2008-06-15 10:55:34 +1000
committerDamien Miller <djm@mindrot.org>2008-06-15 10:55:34 +1000
commit8b7ab960df02da128c56283ce14b78227ac2d200 (patch)
tree7ba374e17f85d4e626732d9a87b56ee17527d27b
parent30fd49e606169c57fef2be66594e24991b2fb747 (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--ChangeLog7
-rw-r--r--openbsd-compat/sigact.c50
2 files changed, 45 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 7ce1aee6f..0bd06cd6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
120080614
2 - (djm) [openbsd-compat/sigact.c] Avoid NULL derefs in ancient sigaction
3 replacement code; patch from ighighi AT gmail.com in bz#1240;
4 ok dtucker
5
120080613 620080613
2 - (dtucker) OpenBSD CVS Sync 7 - (dtucker) OpenBSD CVS Sync
3 - deraadt@cvs.openbsd.org 2008/06/13 09:44:36 8 - deraadt@cvs.openbsd.org 2008/06/13 09:44:36
@@ -4364,4 +4369,4 @@
4364 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4369 OpenServer 6 and add osr5bigcrypt support so when someone migrates
4365 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4370 passwords between UnixWare and OpenServer they will still work. OK dtucker@
4366 4371
4367$Id: ChangeLog,v 1.5010 2008/06/13 23:14:46 dtucker Exp $ 4372$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 8b8e4dd2c..d67845cf1 100644
--- a/openbsd-compat/sigact.c
+++ b/openbsd-compat/sigact.c
@@ -36,6 +36,7 @@
36/* OPENBSD ORIGINAL: lib/libcurses/base/sigaction.c */ 36/* OPENBSD ORIGINAL: lib/libcurses/base/sigaction.c */
37 37
38#include "includes.h" 38#include "includes.h"
39#include <errno.h>
39#include <signal.h> 40#include <signal.h>
40#include "sigact.h" 41#include "sigact.h"
41 42
@@ -47,28 +48,39 @@
47int 48int
48sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) 49sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact)
49{ 50{
50 return sigvec(sig, &(sigact->sv), &(osigact->sv)); 51 return sigvec(sig, sigact ? &sigact->sv : NULL,
52 osigact ? &osigact->sv : NULL);
51} 53}
52 54
53int 55int
54sigemptyset (sigset_t * mask) 56sigemptyset (sigset_t *mask)
55{ 57{
58 if (!mask) {
59 errno = EINVAL;
60 return -1;
61 }
56 *mask = 0; 62 *mask = 0;
57 return 0; 63 return 0;
58} 64}
59 65
60int 66int
61sigprocmask (int mode, sigset_t * mask, sigset_t * omask) 67sigprocmask (int mode, sigset_t *mask, sigset_t *omask)
62{ 68{
63 sigset_t current = sigsetmask(0); 69 sigset_t current = sigsetmask(0);
64 70
65 if (omask) *omask = current; 71 if (!mask) {
72 errno = EINVAL;
73 return -1;
74 }
66 75
67 if (mode==SIG_BLOCK) 76 if (omask)
77 *omask = current;
78
79 if (mode == SIG_BLOCK)
68 current |= *mask; 80 current |= *mask;
69 else if (mode==SIG_UNBLOCK) 81 else if (mode == SIG_UNBLOCK)
70 current &= ~*mask; 82 current &= ~*mask;
71 else if (mode==SIG_SETMASK) 83 else if (mode == SIG_SETMASK)
72 current = *mask; 84 current = *mask;
73 85
74 sigsetmask(current); 86 sigsetmask(current);
@@ -76,28 +88,44 @@ sigprocmask (int mode, sigset_t * mask, sigset_t * omask)
76} 88}
77 89
78int 90int
79sigsuspend (sigset_t * mask) 91sigsuspend (sigset_t *mask)
80{ 92{
93 if (!mask) {
94 errno = EINVAL;
95 return -1;
96 }
81 return sigpause(*mask); 97 return sigpause(*mask);
82} 98}
83 99
84int 100int
85sigdelset (sigset_t * mask, int sig) 101sigdelset (sigset_t *mask, int sig)
86{ 102{
103 if (!mask) {
104 errno = EINVAL;
105 return -1;
106 }
87 *mask &= ~sigmask(sig); 107 *mask &= ~sigmask(sig);
88 return 0; 108 return 0;
89} 109}
90 110
91int 111int
92sigaddset (sigset_t * mask, int sig) 112sigaddset (sigset_t *mask, int sig)
93{ 113{
114 if (!mask) {
115 errno = EINVAL;
116 return -1;
117 }
94 *mask |= sigmask(sig); 118 *mask |= sigmask(sig);
95 return 0; 119 return 0;
96} 120}
97 121
98int 122int
99sigismember (sigset_t * mask, int sig) 123sigismember (sigset_t *mask, int sig)
100{ 124{
125 if (!mask) {
126 errno = EINVAL;
127 return -1;
128 }
101 return (*mask & sigmask(sig)) != 0; 129 return (*mask & sigmask(sig)) != 0;
102} 130}
103 131