summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-06-03 16:20:39 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-06-03 16:20:39 +0000
commit9d478a6659b96a8538eced63153c2b979d72a29d (patch)
tree56b3d53c50626a9d0d26bc7fee20a4b2cfd53d84
parente593fefba7a40df5e69e4a2f98a4a6641926e149 (diff)
zero sigaction before use
-rw-r--r--gnu/usr.bin/cvs/lib/sighandle.c65
-rw-r--r--lib/libc/gen/signal.c3
-rw-r--r--lib/libss/list_rqs.c3
-rw-r--r--lib/libss/listen.c5
-rw-r--r--lib/libss/pager.c3
-rw-r--r--sbin/init/init.c7
-rw-r--r--usr.bin/at/at.c5
-rw-r--r--usr.bin/rlogin/rlogin.c5
-rw-r--r--usr.bin/sup/src/run.c3
-rw-r--r--usr.bin/sup/src/supcmain.c3
-rw-r--r--usr.bin/sup/src/supfilesrv.c4
11 files changed, 60 insertions, 46 deletions
diff --git a/gnu/usr.bin/cvs/lib/sighandle.c b/gnu/usr.bin/cvs/lib/sighandle.c
index 1db41776634..5e552b94f29 100644
--- a/gnu/usr.bin/cvs/lib/sighandle.c
+++ b/gnu/usr.bin/cvs/lib/sighandle.c
@@ -9,11 +9,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ GNU General Public License for more details. */
/* Written by Paul Sander, HaL Computer Systems, Inc. <paul@hal.com>
Brian Berliner <berliner@Sun.COM> added POSIX support */
@@ -30,18 +26,26 @@
* must not themselves make calls to the signal handling
* facilities.
*
- * $CVSid: @(#)sighandle.c 1.13 94/10/07 $
- *
*************************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
+#include "system.h"
#include <sys/types.h>
#include <stdio.h>
#include <signal.h>
+/* Add prototype support. */
+#ifndef PROTO
+#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
+#define PROTO(ARGS) ARGS
+#else
+#define PROTO(ARGS) ()
+#endif
+#endif
+
#ifdef STDC_HEADERS
#include <stdlib.h>
#else
@@ -54,10 +58,6 @@ char *malloc();
#endif /* __STDC__ */
#endif /* STDC_HEADERS */
-#ifdef _MINIX
-#undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */
-#endif
-
/* Define the highest signal number (usually) */
#ifndef SIGMAX
#define SIGMAX 64
@@ -78,19 +78,19 @@ static struct SIG_hlist **SIG_handlers;
/* Define array of default signal vectors */
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
static struct sigaction *SIG_defaults;
#else
#ifdef BSD_SIGNALS
static struct sigvec *SIG_defaults;
#else
-static RETSIGTYPE (**SIG_defaults)();
+static RETSIGTYPE (**SIG_defaults) PROTO ((int));
#endif
#endif
/* Critical section housekeeping */
static int SIG_crSectNest = 0; /* Nesting level */
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
static sigset_t SIG_crSectMask; /* Signal mask */
#else
static int SIG_crSectMask; /* Signal mask */
@@ -103,14 +103,14 @@ static int SIG_crSectMask; /* Signal mask */
static int SIG_init()
{
int i;
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
sigset_t sigset_test;
#endif
if (SIG_defaults && SIG_handlers) /* already allocated */
return (0);
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
(void) sigfillset(&sigset_test);
for (i = 1; i < SIGMAX && sigismember(&sigset_test, i) == 1; i++)
;
@@ -129,8 +129,8 @@ static int SIG_init()
calloc(i, sizeof(struct sigvec));
#else
if (!SIG_defaults)
- SIG_defaults = (RETSIGTYPE (**)())
- calloc(i, sizeof(RETSIGTYPE (**)()));
+ SIG_defaults = (RETSIGTYPE (**) PROTO ((int)) )
+ calloc(i, sizeof(RETSIGTYPE (**) PROTO ((int)) ));
#endif
SIG_crSectMask = 0;
#endif
@@ -144,6 +144,7 @@ static int SIG_init()
* The following invokes each signal handler in the reverse order in which
* they were registered.
*/
+static RETSIGTYPE SIG_handle PROTO ((int));
static RETSIGTYPE SIG_handle(sig)
int sig;
@@ -175,7 +176,7 @@ RETSIGTYPE (*fn)();
{
int val;
struct SIG_hlist *this;
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
struct sigaction act;
sigset_t sigset_mask, sigset_omask;
#else
@@ -191,7 +192,7 @@ RETSIGTYPE (*fn)();
val = 0;
/* Block this signal while we look at handler chain */
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
(void) sigemptyset(&sigset_mask);
(void) sigaddset(&sigset_mask, sig);
(void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask);
@@ -220,19 +221,19 @@ RETSIGTYPE (*fn)();
if (SIG_handlers[sig] == (struct SIG_hlist *) NULL)
{
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
+ memset(&act, 0, sizeof act);
act.sa_handler = SIG_handle;
(void) sigemptyset(&act.sa_mask);
act.sa_flags = 0;
val = sigaction(sig, &act, &SIG_defaults[sig]);
#else
#ifdef BSD_SIGNALS
- bzero((char *)&vec, sizeof(vec));
+ memset (&vec, 0, sizeof (vec));
vec.sv_handler = SIG_handle;
val = sigvec(sig, &vec, &SIG_defaults[sig]);
#else
- if ((SIG_defaults[sig] = signal(sig, SIG_handle)) ==
- (RETSIGTYPE (*)()) -1)
+ if ((SIG_defaults[sig] = signal(sig, SIG_handle)) == SIG_ERR)
val = -1;
#endif
#endif
@@ -257,7 +258,7 @@ RETSIGTYPE (*fn)();
}
/* Unblock the signal */
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
(void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL);
#else
#ifdef BSD_SIGNALS
@@ -280,7 +281,7 @@ RETSIGTYPE (*fn)();
int val;
struct SIG_hlist *this;
struct SIG_hlist *last;
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
sigset_t sigset_mask, sigset_omask;
#else
#ifdef BSD_SIGNALS
@@ -295,7 +296,7 @@ RETSIGTYPE (*fn)();
last = (struct SIG_hlist *) NULL;
/* Block this signal while we look at handler chain */
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
(void) sigemptyset(&sigset_mask);
(void) sigaddset(&sigset_mask, sig);
(void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask);
@@ -330,21 +331,21 @@ RETSIGTYPE (*fn)();
/* Restore default behavior if there are no registered handlers */
if (SIG_handlers[sig] == (struct SIG_hlist *) NULL)
{
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
val = sigaction(sig, &SIG_defaults[sig],
(struct sigaction *) NULL);
#else
#ifdef BSD_SIGNALS
val = sigvec(sig, &SIG_defaults[sig], (struct sigvec *) NULL);
#else
- if (signal(sig, SIG_defaults[sig]) == (RETSIGTYPE (*)()) -1)
+ if (signal(sig, SIG_defaults[sig]) == SIG_ERR)
val = -1;
#endif
#endif
}
/* Unblock the signal */
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
(void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL);
#else
#ifdef BSD_SIGNALS
@@ -365,7 +366,7 @@ void SIG_beginCrSect()
{
if (SIG_crSectNest == 0)
{
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
sigset_t sigset_mask;
(void) sigfillset(&sigset_mask);
@@ -394,7 +395,7 @@ void SIG_endCrSect()
SIG_crSectNest--;
if (SIG_crSectNest == 0)
{
-#ifdef POSIX
+#ifdef POSIX_SIGNALS
(void) sigprocmask(SIG_SETMASK, &SIG_crSectMask, NULL);
#else
#ifdef BSD_SIGNALS
diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c
index 7a501d3748d..a6a2b8b8403 100644
--- a/lib/libc/gen/signal.c
+++ b/lib/libc/gen/signal.c
@@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: signal.c,v 1.2 1996/08/19 08:26:09 tholo Exp $";
+static char rcsid[] = "$OpenBSD: signal.c,v 1.3 1998/06/03 16:20:22 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
/*
@@ -49,6 +49,7 @@ signal(s, a)
{
struct sigaction sa, osa;
+ memset(&sa, 0, sizeof sa);
sa.sa_handler = a;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
diff --git a/lib/libss/list_rqs.c b/lib/libss/list_rqs.c
index 34e8ae877a9..ae5e2c9147d 100644
--- a/lib/libss/list_rqs.c
+++ b/lib/libss/list_rqs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: list_rqs.c,v 1.1 1996/11/15 09:25:29 downsj Exp $ */
+/* $OpenBSD: list_rqs.c,v 1.2 1998/06/03 16:20:27 deraadt Exp $ */
/*-
* Copyright 1987, 1988 by the Student Information Processing Board
@@ -66,6 +66,7 @@ ss_list_requests(argc, argv, sci_idx, info_ptr)
sigaddset(&nmask, SIGINT);
sigprocmask(SIG_BLOCK, &nmask, &omask);
+ memset(&nsig, 0, sizeof nsig);
nsig.sa_handler = SIG_IGN;
sigemptyset(&nsig.sa_mask);
nsig.sa_flags = 0;
diff --git a/lib/libss/listen.c b/lib/libss/listen.c
index f06dfc32f15..b0f0ee1114a 100644
--- a/lib/libss/listen.c
+++ b/lib/libss/listen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: listen.c,v 1.1 1996/11/15 09:25:29 downsj Exp $ */
+/* $OpenBSD: listen.c,v 1.2 1998/06/03 16:20:29 deraadt Exp $ */
/*-
* Copyright 1987, 1988 by the Student Information Processing Board
@@ -38,7 +38,7 @@
#ifndef lint
static char const rcs_id[] =
- "$Id: listen.c,v 1.1 1996/11/15 09:25:29 downsj Exp $";
+ "$Id: listen.c,v 1.2 1998/06/03 16:20:29 deraadt Exp $";
#endif
#ifndef NPOSIX
@@ -114,6 +114,7 @@ ss_listen (sci_idx)
memcpy(old_jmpb, listen_jmpb, sizeof(jmp_buf));
#ifndef NPOSIX
+ memset(&nsig, 0, sizeof nsig);
nsig.sa_handler = listen_int_handler;
sigemptyset(&nsig.sa_mask);
nsig.sa_flags = 0;
diff --git a/lib/libss/pager.c b/lib/libss/pager.c
index 4bdaabc2fa6..2398011bbc8 100644
--- a/lib/libss/pager.c
+++ b/lib/libss/pager.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pager.c,v 1.1 1996/11/15 09:25:30 downsj Exp $ */
+/* $OpenBSD: pager.c,v 1.2 1998/06/03 16:20:30 deraadt Exp $ */
/*-
* Copyright 1987, 1988 by the Student Information Processing Board
@@ -93,6 +93,7 @@ ss_page_stdin()
for (i = 3; i < 32; i++)
(void) close(i);
#ifndef NPOSIX
+ memset(&sa, 0, sizeof sa);
sa.sa_handler = SIG_DFL;
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
diff --git a/sbin/init/init.c b/sbin/init/init.c
index 2cbf47c442a..bda469c5b0d 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.14 1998/05/04 06:37:02 deraadt Exp $ */
+/* $OpenBSD: init.c,v 1.15 1998/06/03 16:20:24 deraadt Exp $ */
/* $NetBSD: init.c,v 1.22 1996/05/15 23:29:33 jtc Exp $ */
/*-
@@ -47,7 +47,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$OpenBSD: init.c,v 1.14 1998/05/04 06:37:02 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: init.c,v 1.15 1998/06/03 16:20:24 deraadt Exp $";
#endif
#endif /* not lint */
@@ -237,6 +237,7 @@ main(argc, argv)
delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS,
SIGXCPU, SIGXFSZ, SIGHUP, SIGTERM, SIGTSTP, SIGALRM, 0);
sigprocmask(SIG_SETMASK, &mask, NULL);
+ memset(&sa, 0, sizeof sa);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
@@ -285,6 +286,7 @@ handle(va_alist)
va_start(ap, handler);
#endif
+ memset(&sa, 0, sizeof sa);
sa.sa_handler = handler;
sigfillset(&mask_everything);
@@ -720,6 +722,7 @@ runcom()
struct sigaction sa;
if ((pid = fork()) == 0) {
+ memset(&sa, 0, sizeof sa);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = SIG_IGN;
diff --git a/usr.bin/at/at.c b/usr.bin/at/at.c
index 12cce81c830..71bb4a29592 100644
--- a/usr.bin/at/at.c
+++ b/usr.bin/at/at.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: at.c,v 1.14 1997/10/06 18:31:01 deraadt Exp $ */
+/* $OpenBSD: at.c,v 1.15 1998/06/03 16:20:26 deraadt Exp $ */
/* $NetBSD: at.c,v 1.4 1995/03/25 18:13:31 glass Exp $ */
/*
@@ -73,7 +73,7 @@ enum { ATQ, ATRM, AT, BATCH, CAT }; /* what program we want to run */
/* File scope variables */
#ifndef lint
-static char rcsid[] = "$OpenBSD: at.c,v 1.14 1997/10/06 18:31:01 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: at.c,v 1.15 1998/06/03 16:20:26 deraadt Exp $";
#endif
char *no_export[] =
@@ -189,6 +189,7 @@ writefile(runtimer, queue)
* Install the signal handler for SIGINT; terminate after removing the
* spool file if necessary
*/
+ memset(&act, 0, sizeof act);
act.sa_handler = sigc;
sigemptyset(&(act.sa_mask));
act.sa_flags = 0;
diff --git a/usr.bin/rlogin/rlogin.c b/usr.bin/rlogin/rlogin.c
index 0cb10e4576d..df6b434e04d 100644
--- a/usr.bin/rlogin/rlogin.c
+++ b/usr.bin/rlogin/rlogin.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rlogin.c,v 1.19 1998/03/25 20:22:08 art Exp $ */
+/* $OpenBSD: rlogin.c,v 1.20 1998/06/03 16:20:33 deraadt Exp $ */
/* $NetBSD: rlogin.c,v 1.8 1995/10/05 09:07:22 mycroft Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93";
#else
-static char rcsid[] = "$OpenBSD: rlogin.c,v 1.19 1998/03/25 20:22:08 art Exp $";
+static char rcsid[] = "$OpenBSD: rlogin.c,v 1.20 1998/06/03 16:20:33 deraadt Exp $";
#endif
#endif /* not lint */
@@ -397,6 +397,7 @@ doit(omask)
* Use sigaction() instead of signal() to avoid getting SIGCHLDs
* for stopped children.
*/
+ memset(&sa, 0, sizeof sa);
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
sa.sa_handler = catch_child;
diff --git a/usr.bin/sup/src/run.c b/usr.bin/sup/src/run.c
index c243a05dd2e..6974bc57189 100644
--- a/usr.bin/sup/src/run.c
+++ b/usr.bin/sup/src/run.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: run.c,v 1.4 1997/04/01 07:35:16 todd Exp $ */
+/* $OpenBSD: run.c,v 1.5 1998/06/03 16:20:35 deraadt Exp $ */
/*
* Copyright (c) 1991 Carnegie Mellon University
@@ -187,6 +187,7 @@ int usepath;
_exit (0377);
}
+ memset(&ignoresig, 0, sizeof ignoresig);
ignoresig.sa_handler = SIG_IGN; /* ignore INT and QUIT signals */
sigemptyset(&ignoresig.sa_mask);
ignoresig.sa_flags = 0;
diff --git a/usr.bin/sup/src/supcmain.c b/usr.bin/sup/src/supcmain.c
index 65c9eb99a9b..aa8a7b32cfb 100644
--- a/usr.bin/sup/src/supcmain.c
+++ b/usr.bin/sup/src/supcmain.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supcmain.c,v 1.7 1997/09/16 11:01:19 deraadt Exp $ */
+/* $OpenBSD: supcmain.c,v 1.8 1998/06/03 16:20:36 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -370,6 +370,7 @@ char **argv;
prtime ();
} else {
/* ignore network pipe signals */
+ memset(&ign, 0, sizeof ign);
ign.sa_handler = SIG_IGN;
ign.sa_flags = 0;
sigemptyset(&ign.sa_mask);
diff --git a/usr.bin/sup/src/supfilesrv.c b/usr.bin/sup/src/supfilesrv.c
index dae2c03811a..b8bbe48653e 100644
--- a/usr.bin/sup/src/supfilesrv.c
+++ b/usr.bin/sup/src/supfilesrv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: supfilesrv.c,v 1.14 1998/05/18 19:13:39 deraadt Exp $ */
+/* $OpenBSD: supfilesrv.c,v 1.15 1998/06/03 16:20:38 deraadt Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -351,12 +351,14 @@ char **argv;
(void) serviceend ();
exit (0);
}
+ memset(&ign, 0, sizeof ign);
ign.sa_handler = SIG_IGN;
sigemptyset(&ign.sa_mask);
ign.sa_flags = 0;
(void) sigaction (SIGHUP,&ign,NULL);
(void) sigaction (SIGINT,&ign,NULL);
(void) sigaction (SIGPIPE,&ign,NULL);
+ memset(&chld, 0, sizeof chld);
chld.sa_handler = chldsig;
sigemptyset(&chld.sa_mask);
chld.sa_flags = 0;