about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2011-08-05 06:43:45 -0400
committerRich Felker <dalias@aerifal.cx>2011-08-05 06:43:45 -0400
commit338b663ddb64ecf8a62ad0d1020a29587e0ca81b (patch)
treee01761774ad2a7ebed6d7538a2295c2b284b4a0b
parent5f37fc132a8f41994f37b6712feb2d4fd34c2be0 (diff)
downloadmusl-338b663ddb64ecf8a62ad0d1020a29587e0ca81b.tar.gz
musl-338b663ddb64ecf8a62ad0d1020a29587e0ca81b.tar.xz
musl-338b663ddb64ecf8a62ad0d1020a29587e0ca81b.zip
fix off-by-one bug in siglongjmp that caused unpredictable behavior
if saved, signal mask would not be restored unless some low signals
were masked. if not saved, signal mask could be wrongly restored to
uninitialized values. in any, wrong mask would be restored.

i believe this function was written for a very old version of the
jmp_buf structure which did not contain a final 0 field for
compatibility with siglongjmp, and never updated...
-rw-r--r--src/signal/siglongjmp.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/signal/siglongjmp.c b/src/signal/siglongjmp.c
index 17129175..600d560c 100644
--- a/src/signal/siglongjmp.c
+++ b/src/signal/siglongjmp.c
@@ -4,7 +4,7 @@
 
 void siglongjmp(sigjmp_buf buf, int ret)
 {
-	unsigned long *flag = buf + sizeof(jmp_buf)/sizeof(long);
+	unsigned long *flag = buf + sizeof(jmp_buf)/sizeof(long) - 1;
 	sigset_t *mask = (void *)(flag + 1);
 	if (*flag)
 		sigprocmask (SIG_SETMASK, mask, NULL);