From: Robert Spalek Date: Thu, 24 Jun 2004 12:30:38 +0000 (+0000) Subject: adapted to the new version of sighandler.c X-Git-Tag: holmes-import~1036 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=8b60734d04936b688ea901b944fee4ba0c269a1a;p=libucw.git adapted to the new version of sighandler.c --- diff --git a/lib/lizard-safe.c b/lib/lizard-safe.c index 6d0b10c9..e265e96a 100644 --- a/lib/lizard-safe.c +++ b/lib/lizard-safe.c @@ -28,7 +28,8 @@ lizard_alloc(uns max_len) die("mmap(anonymous): %m"); if (mprotect(buf->start + buf->len, PAGE_SIZE, PROT_NONE) < 0) die("mprotect: %m"); - buf->old_sigsegv_handler = handle_signal(SIGSEGV); + buf->old_sigsegv_handler = xmalloc(sizeof(struct sigaction)); + handle_signal(SIGSEGV, buf->old_sigsegv_handler); return buf; } @@ -36,16 +37,18 @@ void lizard_free(struct lizard_buffer *buf) { munmap(buf->start, buf->len + PAGE_SIZE); - signal(SIGSEGV, buf->old_sigsegv_handler); + sigaction(SIGSEGV, buf->old_sigsegv_handler, NULL); + xfree(buf->old_sigsegv_handler); xfree(buf); } static jmp_buf safe_decompress_jump; -static void -sigsegv_handler(void) +static int +sigsegv_handler(int signal UNUSED) { log(L_ERROR, "SIGSEGV caught in lizard_decompress()"); longjmp(safe_decompress_jump, 1); + return 1; } int @@ -61,7 +64,7 @@ lizard_decompress_safe(byte *in, struct lizard_buffer *buf, uns expected_length) errno = EFBIG; return -1; } - volatile my_sighandler_t old_handler = signal_handler[SIGSEGV]; + volatile sh_sighandler_t old_handler = signal_handler[SIGSEGV]; signal_handler[SIGSEGV] = sigsegv_handler; int len, err; if (!setjmp(safe_decompress_jump)) diff --git a/lib/lizard.h b/lib/lizard.h index 35200c08..fc3631ac 100644 --- a/lib/lizard.h +++ b/lib/lizard.h @@ -28,10 +28,11 @@ int lizard_compress(byte *in, uns in_len, byte *out); int lizard_decompress(byte *in, byte *out); /* lizard-safe.c */ +struct sigaction; struct lizard_buffer { uns len; void *start, *ptr; - void *old_sigsegv_handler; + struct sigaction *old_sigsegv_handler; }; struct lizard_buffer *lizard_alloc(uns max_len);