sighold and invalid signal numbers.
Martin Schwidefsky
schwidefsky@de.ibm.com
Wed May 14 14:19:00 GMT 2003
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;
More information about the Libc-alpha
mailing list