diff options
author | Yann Collet <cyan@fb.com> | 2019-04-05 18:47:06 (GMT) |
---|---|---|
committer | Yann Collet <cyan@fb.com> | 2019-04-05 18:47:06 (GMT) |
commit | a4f1635b0a29580628c22fbccfd68bda122453bb (patch) | |
tree | 131e32fa42c54839b64f0176b6cfc8936606c13a | |
parent | c3f8928f879f5ce89d9c32996ea991312e6c69ec (diff) | |
download | lz4-a4f1635b0a29580628c22fbccfd68bda122453bb.zip lz4-a4f1635b0a29580628c22fbccfd68bda122453bb.tar.gz lz4-a4f1635b0a29580628c22fbccfd68bda122453bb.tar.bz2 |
fuzzer: fixed strict c99 with mmap+MAP_ANONYMOUS
-rw-r--r-- | tests/frametest.c | 9 | ||||
-rw-r--r-- | tests/fuzzer.c | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/tests/frametest.c b/tests/frametest.c index 14906a0..fa005db 100644 --- a/tests/frametest.c +++ b/tests/frametest.c @@ -270,7 +270,7 @@ int basicTests(U32 seed, double compressibility) if (decResult != 0) goto _output_error; /* should finish now */ op += oSize; if (op>oend) { DISPLAY("decompression write overflow \n"); goto _output_error; } - { U64 const crcDest = XXH64(decodedBuffer, op-ostart, 1); + { U64 const crcDest = XXH64(decodedBuffer, (size_t)(op-ostart), 1); if (crcDest != crcOrig) goto _output_error; } } @@ -309,7 +309,6 @@ int basicTests(U32 seed, double compressibility) iSize = 15 - iSize; CHECK( LZ4F_getFrameInfo(dCtx, &fi, ip, &iSize) ); DISPLAYLEVEL(3, " correctly decoded \n"); - ip += iSize; } DISPLAYLEVEL(3, "Decode a buggy input : "); @@ -337,7 +336,7 @@ int basicTests(U32 seed, double compressibility) const BYTE* ip = (const BYTE*) compressedBuffer; const BYTE* const iend = ip + cSize; while (ip < iend) { - size_t oSize = oend-op; + size_t oSize = (size_t)(oend-op); size_t iSize = 1; CHECK( LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, NULL) ); op += oSize; @@ -380,8 +379,8 @@ int basicTests(U32 seed, double compressibility) while (ip < iend) { unsigned const nbBits = FUZ_rand(&randState) % maxBits; size_t iSize = (FUZ_rand(&randState) & ((1<<nbBits)-1)) + 1; - size_t oSize = oend-op; - if (iSize > (size_t)(iend-ip)) iSize = iend-ip; + size_t oSize = (size_t)(oend-op); + if (iSize > (size_t)(iend-ip)) iSize = (size_t)(iend-ip); CHECK( LZ4F_decompress(dCtx, op, &oSize, ip, &iSize, NULL) ); op += oSize; ip += iSize; diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 6ebbf20..4cc80fa 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -37,6 +37,7 @@ * Dependencies **************************************/ #if defined(__unix__) && !defined(_AIX) /* must be included before platform.h for MAP_ANONYMOUS */ +# define _GNU_SOURCE /* MAP_ANONYMOUS even in -std=c99 mode */ # include <sys/mman.h> /* mmap */ #endif #include "platform.h" /* _CRT_SECURE_NO_WARNINGS */ @@ -47,9 +48,6 @@ #include <time.h> /* clock_t, clock, CLOCKS_PER_SEC */ #include <assert.h> #include <limits.h> /* INT_MAX */ -#if defined(__unix__) && defined(_AIX) -# include <sys/mman.h> /* mmap */ -#endif #define LZ4_DISABLE_DEPRECATE_WARNINGS /* LZ4_decompress_fast */ #define LZ4_STATIC_LINKING_ONLY |