This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
sighold and invalid signal numbers.
- From: Martin Schwidefsky <schwidefsky at de dot ibm dot com>
- To: libc-alpha at sources dot redhat dot com
- Date: Wed, 14 May 2003 16:18:09 +0200
- Subject: sighold and invalid signal numbers.
Hi,
libc crashes if sighold is called with an invalid signal number.
The standard say that it is supposed to return with -1 and
errno=EINVAL. The reason is the __SIGSETFN optimization of
sigaddset in sysdeps/unix/sysv/linux/bits/sigset.h. The comment
says that the __ version of sigaddset should not check for bogus
signal numbers. Conclusion is that sighold needs to check it.
Any better ideas ?
blue skies,
Martin.
diff -urN libc/signal/sighold.c libc-sighold/signal/sighold.c
--- libc/signal/sighold.c Tue Apr 29 17:49:29 2003
+++ libc-sighold/signal/sighold.c Wed May 14 16:09:25 2003
@@ -28,6 +28,12 @@
{
sigset_t set;
+ if (sig <= 0 || sig >= NSIG)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
/* Retrieve current signal set. */
if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)
return -1;