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...
This commit is contained in:
Rich Felker 2011-08-05 06:43:45 -04:00
parent 5f37fc132a
commit 338b663ddb
1 changed files with 1 additions and 1 deletions

View File

@ -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);