fuzzer: fixed strict c99 with mmap+MAP_ANONYMOUS

This commit is contained in:
Yann Collet 2019-04-05 11:47:06 -07:00
parent c3f8928f87
commit a4f1635b0a
2 changed files with 5 additions and 8 deletions

View File

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

View File

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