possible off-by-one bug in signal.c:sigishandled

( Marc A. Lehmann ) pcg at goof.com
Fri Feb 8 17:48:05 UTC 2002


while tracing a process with -p, i found that starce just exits aber the
process sends itself a SIGUSR1. the reason is that sigishandled checks the
signal maks by doing 1<<signum, but it seems 1<<(signum-1) is the correct
formula. I am sure you can find out wether this is a proper fix or not
much faster than me, but with the patch below, strace -p works fine here
(linux-2.4.18, in acse this is kernel-specific ;)

--- signal.c.old	Sat Feb  9 02:43:21 2002
+++ signal.c	Sat Feb  9 02:46:16 2002
@@ -449,10 +449,10 @@
 	s += sscanf(s, "%qx", &caught);
 
 #ifdef DEBUG
-	fprintf(stderr, "sigs: %08x %08x %08x %08x\n",
+	fprintf(stderr, "sigs: %08qx %08qx %08qx %08qx\n",
 		signalled, blocked, ignored, caught);
 #endif
-	if ((ignored & (1ULL << sig)) || (caught & (1ULL << sig)))
+	if ((ignored & (1ULL << (sig-1))) || (caught & (1ULL << (sig-1))))
 		return 1;
 #endif /* LINUX */
 
-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg at goof.com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |




More information about the Strace-devel mailing list