This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]