X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Flizard-safe.c;h=0aa218ddc12b9b206f6ce134f9232d2b3639bec3;hb=a6368763d08042207963c941b1c52b5fafcb0cb3;hp=ba7d8df34cdb05a9602735e2ea0aea266b3a8be1;hpb=e8060fa4647c5c4ccf07efb91a35f65c543dfc4f;p=libucw.git diff --git a/ucw/lizard-safe.c b/ucw/lizard-safe.c index ba7d8df3..0aa218dd 100644 --- a/ucw/lizard-safe.c +++ b/ucw/lizard-safe.c @@ -7,9 +7,10 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/threads.h" -#include "ucw/lizard.h" +#include +#include +#include +#include #include #include @@ -18,7 +19,7 @@ #include struct lizard_buffer { - uns len; + uint len; void *ptr; }; @@ -42,7 +43,7 @@ lizard_free(struct lizard_buffer *buf) } static void -lizard_realloc(struct lizard_buffer *buf, uns max_len) +lizard_realloc(struct lizard_buffer *buf, uint max_len) /* max_len needs to be aligned to CPU_PAGE_SIZE */ { if (max_len <= buf->len) @@ -55,7 +56,7 @@ lizard_realloc(struct lizard_buffer *buf, uns max_len) buf->len = max_len; buf->ptr = mmap(NULL, buf->len + CPU_PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (buf->ptr == MAP_FAILED) - die("mmap(anonymous, %d bytes): %m", (uns)(buf->len + CPU_PAGE_SIZE)); + die("mmap(anonymous, %d bytes): %m", (uint)(buf->len + CPU_PAGE_SIZE)); if (mprotect(buf->ptr + buf->len, CPU_PAGE_SIZE, PROT_NONE) < 0) die("mprotect: %m"); } @@ -69,14 +70,9 @@ sigsegv_handler(int signal UNUSED) } byte * -lizard_decompress_safe(const byte *in, struct lizard_buffer *buf, uns expected_length) - /* Decompresses in into buf, sets *ptr to the data, and returns the - * uncompressed length. If an error has occured, -1 is returned and errno is - * set. The buffer buf is automatically reallocated. SIGSEGV is caught in - * case of buffer-overflow. The function is not re-entrant because of a - * static longjmp handler. */ +lizard_decompress_safe(const byte *in, struct lizard_buffer *buf, uint expected_length) { - uns lock_offset = ALIGN_TO(expected_length + 3, CPU_PAGE_SIZE); // +3 due to the unaligned access + uint lock_offset = ALIGN_TO(expected_length + 3, CPU_PAGE_SIZE); // +3 due to the unaligned access if (lock_offset > buf->len) lizard_realloc(buf, lock_offset); volatile ucw_sighandler_t old_handler = set_signal_handler(SIGSEGV, sigsegv_handler);