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 @@ | |||
1 | 20080614 | ||
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 | |||
1 | 20080613 | 6 | 20080613 |
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 @@ | |||
47 | int | 48 | int |
48 | sigaction(int sig, struct sigaction *sigact, struct sigaction *osigact) | 49 | sigaction(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 | ||
53 | int | 55 | int |
54 | sigemptyset (sigset_t * mask) | 56 | sigemptyset (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 | ||
60 | int | 66 | int |
61 | sigprocmask (int mode, sigset_t * mask, sigset_t * omask) | 67 | sigprocmask (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 | ||
78 | int | 90 | int |
79 | sigsuspend (sigset_t * mask) | 91 | sigsuspend (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 | ||
84 | int | 100 | int |
85 | sigdelset (sigset_t * mask, int sig) | 101 | sigdelset (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 | ||
91 | int | 111 | int |
92 | sigaddset (sigset_t * mask, int sig) | 112 | sigaddset (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 | ||
98 | int | 122 | int |
99 | sigismember (sigset_t * mask, int sig) | 123 | sigismember (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 | ||