30 # pragma warning(disable : 26451)
45 #define LZ4F_STATIC_LINKING_ONLY
48 #define LZ4_STATIC_LINKING_ONLY
50 #define XXH_STATIC_LINKING_ONLY
58 dstPtr[0] = (
BYTE) value32;
59 dstPtr[1] = (
BYTE)(value32 >> 8);
60 dstPtr[2] = (
BYTE)(value32 >> 16);
61 dstPtr[3] = (
BYTE)(value32 >> 24);
68 #define LZ4F_MAGIC_SKIPPABLE_START 0x184D2A50U
75 #define FUZ_COMPRESSIBILITY_DEFAULT 50
83 #define DISPLAY(...) fprintf(stderr, __VA_ARGS__)
84 #define DISPLAYLEVEL(l, ...) if (displayLevel>=l) { DISPLAY(__VA_ARGS__); }
85 #define DISPLAYUPDATE(l, ...) if (displayLevel>=l) { \
86 if ((FUZ_GetClockSpan(g_clockTime) > refreshRate) || (displayLevel>=4)) \
87 { g_clockTime = clock(); DISPLAY(__VA_ARGS__); \
88 if (displayLevel>=4) fflush(stdout); } }
104 #define MIN(a,b) ( (a) < (b) ? (a) : (b) )
105 #define MAX(a,b) ( (a) > (b) ? (a) : (b) )
109 return clock() - clockStart;
113 #define FUZ_rotl32(x,r) ((x << r) | (x >> (32 - r)))
125 #define FUZ_RAND15BITS (FUZ_rand(seed) & 0x7FFF)
126 #define FUZ_RANDLENGTH ( (FUZ_rand(seed) & 3) ? (FUZ_rand(seed) % 15) : (FUZ_rand(seed) % 510) + 15)
131 U32 P32 = (
U32)(32768 * proba);
136 while (
pos < bufferSize) {
141 size_t const length =
MIN(lengthRand, bufferSize -
pos);
150 size_t const length =
MIN(lengthRand, bufferSize -
pos);
160 if (v32==0)
return 0;
161 while (v32) {v32 >>= 1; nbBits ++;}
169 #define CHECK_V(v,f) v = f; if (LZ4F_isError(v)) { fprintf(stderr, "%s \n", LZ4F_getErrorName(v)); goto _output_error; }
170 #define CHECK(f) { LZ4F_errorCode_t const CHECK_V(err_ , f); }
174 #define COMPRESSIBLE_NOISE_LENGTH (2 MB)
177 void*
const compressedBuffer =
malloc(cBuffSize);
179 U32 randState = seed;
180 size_t cSize, testSize;
184 int basicTests_error = 0;
186 memset(&prefs, 0,
sizeof(prefs));
188 if (!CNBuffer || !compressedBuffer || !decodedBuffer) {
189 DISPLAY(
"allocation error, not enough memory to start fuzzer tests \n");
198 if (cBound < 64
KB)
goto _output_error;
203 DISPLAYLEVEL(3,
"LZ4F_compressBound(1 KB, autoFlush=1) = ");
206 memset(&autoFlushPrefs, 0,
sizeof(autoFlushPrefs));
209 if (cBound > 64
KB)
goto _output_error;
214 DISPLAYLEVEL(3,
"LZ4F_compressBound(1 KB, autoFlush=0) = ");
216 if (cBound < 64
KB)
goto _output_error;
222 DISPLAYLEVEL(3,
"LZ4F_compressFrame, compress null content : ");
224 DISPLAYLEVEL(3,
"null content encoded into a %u bytes frame \n", (
unsigned)cSize);
229 DISPLAYLEVEL(3,
"LZ4F_getFrameInfo on null-content frame (#157) \n");
233 size_t avail_in = fhs;
236 if (avail_in != fhs)
goto _output_error;
246 DISPLAYLEVEL(3,
"LZ4F_compressFrame, using fast level -3 : ");
248 memset(&fastCompressPrefs, 0,
sizeof(fastCompressPrefs));
251 DISPLAYLEVEL(3,
"Compressed %u bytes into a %u bytes frame \n", (
U32)testSize, (
U32)cSize);
254 DISPLAYLEVEL(3,
"LZ4F_compressFrame, using default preferences : ");
256 DISPLAYLEVEL(3,
"Compressed %u bytes into a %u bytes frame \n", (
U32)testSize, (
U32)cSize);
260 size_t compressedBufferSize = cSize;
266 {
U64 const crcDest =
XXH64(decodedBuffer, decodedBufferSize, 1);
267 if (crcDest != crcOrig)
goto _output_error; }
271 {
size_t const missingBytes = 4;
272 size_t iSize = compressedBufferSize - missingBytes;
273 const BYTE* cBuff = (
const BYTE*) compressedBuffer;
274 BYTE*
const ostart = (
BYTE*)decodedBuffer;
280 if (decResult != missingBytes) {
281 DISPLAY(
"%u bytes missing != %u bytes requested \n", (
U32)missingBytes, (
U32)decResult);
284 DISPLAYLEVEL(3,
"indeed, requests %u bytes \n", (
unsigned)decResult);
290 if (decResult != 0)
goto _output_error;
292 if (
op>oend) {
DISPLAY(
"decompression write overflow \n");
goto _output_error; }
293 {
U64 const crcDest =
XXH64(decodedBuffer, (
size_t)(
op-ostart), 1);
294 if (crcDest != crcOrig)
goto _output_error;
302 DISPLAYLEVEL(3,
"Start by feeding 0 bytes, to get next input size : ");
307 DISPLAYLEVEL(3,
"LZ4F_getFrameInfo on zero-size input : ");
308 {
size_t nullSize = 0;
311 DISPLAYLEVEL(3,
"incorrect error : %s != ERROR_frameHeader_incomplete \n",
318 DISPLAYLEVEL(3,
"LZ4F_getFrameInfo on not enough input : ");
328 DISPLAYLEVEL(3,
"LZ4F_getFrameInfo on enough input : ");
338 memcpy(decodedBuffer, (
char*)compressedBuffer+16, 32);
339 memcpy((
char*)compressedBuffer+16, (
const char*)decodedBuffer+32, 32);
341 size_t cbSize = cSize;
342 size_t const decompressError =
LZ4F_decompress(dCtx, decodedBuffer, &dbSize,
343 compressedBuffer, &cbSize,
348 memcpy((
char*)compressedBuffer+16, decodedBuffer, 32);
350 DISPLAYLEVEL(3,
"Reset decompression context, since it's left in error state \n");
354 {
BYTE*
const ostart = (
BYTE*)decodedBuffer;
357 const BYTE*
ip = (
const BYTE*) compressedBuffer;
358 const BYTE*
const iend =
ip + cSize;
367 if (crcDest != crcOrig)
goto _output_error;
377 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
382 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
388 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
393 BYTE*
const ostart = (
BYTE*)decodedBuffer;
396 const BYTE*
ip = (
const BYTE*)compressedBuffer;
397 const BYTE*
const iend = (
const BYTE*)compressedBuffer + cSize;
401 unsigned const nbBits =
FUZ_rand(&randState) % maxBits;
402 size_t iSize = (
FUZ_rand(&randState) & ((1<<nbBits)-1)) + 1;
404 if (iSize > (
size_t)(iend-
ip)) iSize = (
size_t)(iend-
ip);
409 {
size_t const decodedSize = (
size_t)(
op - ostart);
410 U64 const crcDest =
XXH64(decodedBuffer, decodedSize, 1);
411 if (crcDest != crcOrig)
goto _output_error;
422 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
428 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
433 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
441 DISPLAYLEVEL(3,
"Compressed %u bytes into a %u bytes frame \n", (
U32)testSize, (
U32)cSize);
449 DISPLAYLEVEL(3,
"Compressed %u bytes into a %u bytes frame \n", (
U32)testSize, (
U32)cSize);
452 DISPLAYLEVEL(3,
"LZ4F_compressFrame with block checksum : ");
453 memset(&prefs, 0,
sizeof(prefs));
456 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)cSize);
459 {
size_t iSize = cSize;
464 if (decodedSize != testSize)
goto _output_error;
465 if (iSize != cSize)
goto _output_error;
466 {
U64 const crcDest =
XXH64(decodedBuffer, decodedSize, 1);
467 U64 const crcSrc =
XXH64(CNBuffer, testSize, 1);
468 if (crcDest != crcSrc)
goto _output_error;
477 BYTE*
const ostart = (
BYTE*)compressedBuffer;
488 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)(
op-ostart));
498 DISPLAYLEVEL(3,
"Compressed %i bytes into a %i bytes frame \n", (
int)testSize, (
int)(
op-ostart));
517 U32 const dictID = 0x99;
524 DISPLAYLEVEL(3,
"created frame header of size %i bytes \n", (
int)cErr);
538 {
size_t const dictSize = 63
KB;
540 size_t cSizeNoDict, cSizeWithDict;
542 if (cdict ==
NULL)
goto _output_error;
545 DISPLAYLEVEL(3,
"LZ4F_compressFrame_usingCDict, with NULL dict : ");
554 DISPLAYLEVEL(3,
"LZ4F_compressFrame_usingCDict, with dict : ");
560 (
unsigned)dictSize, (
unsigned)cSizeWithDict);
561 if ((LZ4_DISTANCE_MAX > dictSize) && (cSizeWithDict >= cSizeNoDict))
goto _output_error;
562 crcOrig =
XXH64(CNBuffer, dictSize, 0);
570 decodedBuffer, &decodedSize,
575 if (decodedSize != dictSize)
goto _output_error;
576 {
U64 const crcDest =
XXH64(decodedBuffer, decodedSize, 0);
577 if (crcDest != crcOrig)
goto _output_error; }
582 DISPLAYLEVEL(3,
"LZ4F_compressFrame_usingCDict, with dict, negative level : ");
583 {
size_t cSizeLevelMax;
585 memset(&cParams, 0,
sizeof(cParams));
591 DISPLAYLEVEL(3,
"%u bytes \n", (
unsigned)cSizeLevelMax);
594 DISPLAYLEVEL(3,
"LZ4F_compressFrame_usingCDict, with dict, level max : ");
595 {
size_t cSizeLevelMax;
597 memset(&cParams, 0,
sizeof(cParams));
603 DISPLAYLEVEL(3,
"%u bytes \n", (
unsigned)cSizeLevelMax);
606 DISPLAYLEVEL(3,
"LZ4F_compressFrame_usingCDict, multiple linked blocks : ");
607 {
size_t cSizeContiguous;
608 size_t const inSize = dictSize * 3;
611 memset(&cParams, 0,
sizeof(cParams));
619 (
unsigned)inSize, (
unsigned)cSizeContiguous);
621 DISPLAYLEVEL(3,
"LZ4F_decompress_usingDict on multiple linked blocks : ");
627 decodedBuffer, &decodedSize,
632 if (decodedSize != inSize)
goto _output_error;
633 crcOrig =
XXH64(CNBuffer, inSize, 0);
634 {
U64 const crcDest =
XXH64(decodedBuffer, decodedSize, 0);
635 if (crcDest != crcOrig)
goto _output_error; }
642 DISPLAYLEVEL(3,
"LZ4F_compressFrame_usingCDict, multiple independent blocks : ");
644 size_t const inSize = dictSize * 3;
647 memset(&cParams, 0,
sizeof(cParams));
655 (
unsigned)inSize, (
unsigned)cSizeIndep);
657 DISPLAYLEVEL(3,
"LZ4F_decompress_usingDict on multiple independent blocks : ");
663 decodedBuffer, &decodedSize,
668 if (decodedSize != inSize)
goto _output_error;
669 crcOrig =
XXH64(CNBuffer, inSize, 0);
670 {
U64 const crcDest =
XXH64(decodedBuffer, decodedSize, 0);
671 if (crcDest != crcOrig)
goto _output_error; }
683 unsigned blockSizeID;
684 for (blockSizeID = 4; blockSizeID < 8; ++blockSizeID) {
687 DISPLAYLEVEL(3,
"Returned block size of %u bytes for blockID %u \n",
688 (
unsigned)result, blockSizeID);
711 BYTE* iend = (
BYTE*)compressedBuffer + cSize + 8;
721 unsigned nbBits =
FUZ_rand(&randState) % maxBits;
722 size_t iSize = (
FUZ_rand(&randState) & ((1<<nbBits)-1)) + 1;
724 if (iSize > (
size_t)(iend-
ip)) iSize = (
size_t)(iend-
ip);
729 DISPLAYLEVEL(3,
"Skipped %i bytes \n", (
int)decodedBufferSize);
733 ip = (
BYTE*)compressedBuffer;
734 op = (
BYTE*)decodedBuffer;
740 unsigned const nbBits =
FUZ_rand(&randState) % maxBits;
741 size_t iSize = (
FUZ_rand(&randState) & ((1<<nbBits)-1)) + 1;
743 if (iSize > (
size_t)(iend-
ip)) iSize = (
size_t)(iend-
ip);
750 DISPLAYLEVEL(3,
"Skippable frame header complete in first call \n");
751 ip = (
BYTE*)compressedBuffer;
752 op = (
BYTE*)decodedBuffer;
759 if (iSize > (
size_t)(iend-
ip)) iSize = (
size_t)(iend-
ip);
767 DISPLAY(
"Basic tests completed \n");
770 free(compressedBuffer);
774 return basicTests_error;
777 basicTests_error = 1;
778 DISPLAY(
"Error detected ! \n");
791 DISPLAY(
"locateBuffDiff: looking for error position \n");
793 DISPLAY(
"mode %i: non-contiguous output (%u bytes), cannot search \n",
794 (
int)o_scenario, (
unsigned)
size);
804 # define EXIT_MSG(...) { DISPLAY("Error => "); DISPLAY(__VA_ARGS__); \
805 DISPLAY(" (seed %u, test nb %u) \n", seed, testNb); exit(1); }
807 # define CHECK(cond, ...) { if (cond) { EXIT_MSG(__VA_ARGS__); } }
811 const void* cSrc,
size_t cSize,
813 const void* srcRef,
size_t decompressedSize,
815 U32*
const randState,
821 const BYTE*
const iend =
ip + cSize;
824 BYTE*
const oend =
op + dstCapacity;
827 unsigned const maxBits =
MAX(3, suggestedBits);
829 size_t moreToFlush = 0;
834 unsigned const nbBitsI = (
FUZ_rand(randState) % (maxBits-1)) + 1;
835 unsigned const nbBitsO = (
FUZ_rand(randState) % (maxBits)) + 1;
836 size_t const iSizeCand = (
FUZ_rand(randState) & ((1<<nbBitsI)-1)) + 1;
837 size_t const iSizeMax =
MIN(iSizeCand, (
size_t)(iend-
ip));
838 size_t iSize = iSizeMax;
839 size_t const oSizeCand = (
FUZ_rand(randState) & ((1<<nbBitsO)-1)) + 2;
840 size_t const oSizeMax =
MIN(oSizeCand, (
size_t)(oend-
op));
841 int const sentinelTest = (
op + oSizeMax < oend);
842 size_t oSize = oSizeMax;
845 memset(&dOptions, 0,
sizeof(dOptions));
848 if (sentinelTest)
op[oSizeMax] = mark;
850 DISPLAYLEVEL(7,
"dstCapacity=%u, presentedInput=%u \n", (
unsigned)oSize, (
unsigned)iSize);
853 {
void*
const iBuffer =
malloc(iSizeMax);
854 void*
const tmpop = (
FUZ_rand(randState) & (oSize == 0)) ?
NULL :
op;
855 const void*
const tmpip = (
FUZ_rand(randState) & (iSize == 0)) ?
NULL : iBuffer;
858 moreToFlush =
LZ4F_decompress(dCtx, tmpop, &oSize, tmpip, &iSize, &dOptions);
861 DISPLAYLEVEL(7,
"oSize=%u, readSize=%u \n", (
unsigned)oSize, (
unsigned)iSize);
864 CHECK(
op[oSizeMax] != mark,
"op[oSizeMax] = %02X != %02X : "
865 "Decompression overwrites beyond assigned dst size",
869 if (findErrorPos)
DISPLAYLEVEL(2,
"checksum error detected \n");
879 if (
op == oend)
return LZ4F_ERROR_GENERIC;
887 if (moreToFlush != 0)
return LZ4F_ERROR_decompressionFailed;
890 if (crcDecoded != crcOrig) {
892 return LZ4F_ERROR_contentChecksum_invalid;
899 const void* srcRef,
size_t decompressedSize,
901 U32*
const randState,
909 (decompressedSize * 2) + 128 :
912 void*
const dstBuffer =
malloc(dstCapacity);
916 dstBuffer, dstCapacity, o_scenario,
917 srcRef, decompressedSize,
921 seed, testNb, findErrorPos);
928 int fuzzerTests(
U32 seed,
unsigned nbTests,
unsigned startTest,
double compressibility,
U32 duration_s)
931 size_t const CNBufferLength = 9
MB;
932 void* CNBuffer =
NULL;
934 void* compressedBuffer =
NULL;
935 void* decodedBuffer =
NULL;
940 clock_t const startClock = clock();
941 clock_t const clockDuration = duration_s * CLOCKS_PER_SEC;
945 CHECK(
LZ4F_isError(creationStatus),
"Allocation failed (error %i)", (
int)creationStatus); }
947 CHECK(
LZ4F_isError(creationStatus),
"Allocation failed (error %i)", (
int)creationStatus); }
949 CHECK(
LZ4F_isError(creationStatus),
"Allocation failed (error %i)", (
int)creationStatus); }
950 CNBuffer =
malloc(CNBufferLength);
951 CHECK(CNBuffer==
NULL,
"CNBuffer Allocation failed");
952 compressedBuffer =
malloc(compressedBufferSize);
953 CHECK(compressedBuffer==
NULL,
"compressedBuffer Allocation failed");
954 decodedBuffer =
calloc(1, CNBufferLength);
955 CHECK(decodedBuffer==
NULL,
"decodedBuffer Allocation failed");
959 for (testNb =0; (testNb < startTest); testNb++) (
void)
FUZ_rand(&coreRand);
962 for ( ; (testNb < nbTests) || (clockDuration >
FUZ_GetClockSpan(startClock)) ; testNb++) {
966 size_t const srcStartId =
FUZ_rand(&randState) % (CNBufferLength -
srcSize);
967 const BYTE*
const srcStart = (
const BYTE*)CNBuffer + srcStartId;
968 unsigned const neverFlush = (
FUZ_rand(&randState) & 15) == 1;
975 memset(&prefs, 0,
sizeof(prefs));
987 if ((
FUZ_rand(&randState) & 0xFFF) == 0) {
994 }
else if ((
FUZ_rand(&randState) & 0xF) == 2) {
999 const BYTE*
ip = srcStart;
1005 memset(&cOptions, 0,
sizeof(cOptions));
1012 unsigned const nbBitsSeg =
FUZ_rand(&randState) % maxBits;
1013 size_t const sampleMax = (
FUZ_rand(&randState) & ((1<<nbBitsSeg)-1)) + 1;
1014 size_t const iSize =
MIN(sampleMax, (
size_t)(iend-
ip));
1018 DISPLAYLEVEL(6,
"Sending %u bytes to compress (stableSrc:%u) \n",
1027 {
unsigned const forceFlush = neverFlush ? 0 : ((
FUZ_rand(&randState) & 3) == 1);
1029 size_t const flushSize =
LZ4F_flush(cCtx,
op, (
size_t)(oend-
op), &cOptions);
1030 DISPLAYLEVEL(6,
"flushing %u bytes \n", (
unsigned)flushSize);
1031 CHECK(
LZ4F_isError(flushSize),
"Compression failed (error %i)", (
int)flushSize);
1033 if ((
FUZ_rand(&randState) % 1024) == 3) {
1035 op[0] =
op[1] =
op[2] = 0;
1042 op[2] = (
BYTE)(bc32>>16);
1043 op[3] = (
BYTE)(bc32>>24);
1047 CHECK(
op>=oend,
"LZ4F_compressFrameBound overflow");
1049 int const tooSmallDstEnd = ((
FUZ_rand(&randState) & 31) == 3);
1050 size_t const dstEndTooSmallSize = (
FUZ_rand(&randState) % dstEndSafeSize) + 1;
1051 size_t const dstEndSize = tooSmallDstEnd ? dstEndTooSmallSize : dstEndSafeSize;
1055 (
unsigned)((
size_t)(
op - (
BYTE*)compressedBuffer) + dstEndSize),
1056 (
unsigned)compressedBufferSize);
1057 assert(
op + dstEndSize < (
BYTE*)compressedBuffer + compressedBufferSize);
1058 op[dstEndSize] = canaryByte;
1060 CHECK(
op[dstEndSize] != canaryByte,
"LZ4F_compressEnd writes beyond dstCapacity !");
1062 if (tooSmallDstEnd)
continue;
1063 CHECK(!tooSmallDstEnd,
"Compression completion failed (error %i : %s)",
1076 CHECK (
LZ4F_isError(result),
"multi-segment decompression failed (error %i => %s)",
1086 {
U32 const nbBits =
FUZ_rand(&randState) % maxNbBits;
1087 size_t const mask = (1<<nbBits) - 1;
1091 if (
pos >= cSize)
break;
1093 {
U32 const nbBitsCodes =
FUZ_rand(&randState) % maxNbBits;
1094 U32 const nbBits = nbBitsCodes ? nbBitsCodes-1 : 0;
1095 size_t const mask = (1<<nbBits) - 1;
1096 size_t const rNoiseLength = (
FUZ_rand(&randState) &
mask) + 1;
1097 size_t const noiseLength =
MIN(rNoiseLength, cSize-
pos);
1098 size_t const noiseStart =
FUZ_rand(&randState) % (CNBufferLength - noiseLength);
1099 memcpy((
BYTE*)compressedBuffer +
pos, (
const char*)CNBuffer + noiseStart, noiseLength);
1119 free(compressedBuffer);
1120 free(decodedBuffer);
1123 DISPLAY(
"press enter to finish \n");
1133 DISPLAY(
" %s [args]\n", programName);
1137 DISPLAY(
" -T# : Duration of tests, in seconds (default: use Nb of tests) \n");
1138 DISPLAY(
" -s# : Select seed (default:prompt user)\n");
1139 DISPLAY(
" -t# : Select starting test number (default:0)\n");
1142 DISPLAY(
" -h : display help and exit\n");
1153 unsigned testNb = 0;
1157 const char*
const programName =
argv[0];
1160 for (argNb=1; argNb<argc; argNb++) {
1161 const char* argument =
argv[argNb];
1163 if(!argument)
continue;
1166 if (argument[0]==
'-') {
1167 if (!strcmp(argument,
"--no-prompt")) {
1175 while (*argument!=0) {
1195 nbTests=0; duration=0;
1196 while ((*argument>=
'0') && (*argument<=
'9')) {
1198 nbTests += (
unsigned)(*argument -
'0');
1205 nbTests = 0; duration = 0;
1209 case 'm': duration *= 60; argument++;
continue;
1211 case 'n': argument++;
continue;
1221 case '9': duration *= 10; duration += (
U32)(*argument++ -
'0');
continue;
1231 while ((*argument>=
'0') && (*argument<=
'9')) {
1233 seed += (
U32)(*argument -
'0');
1240 while ((*argument>=
'0') && (*argument<=
'9')) {
1242 testNb += (
unsigned)(*argument -
'0');
1249 while ((*argument>=
'0') && (*argument<=
'9')) {
1251 proba += *argument -
'0';
1254 if (proba<0) proba=0;
1255 if (proba>100) proba=100;
1276 nbTests += (nbTests==0);
1278 if (testNb==0) result =
basicTests(seed, ((
double)proba) / 100);
1279 if (result)
return 1;
1280 return fuzzerTests(seed, nbTests, testNb, ((
double)proba) / 100, duration);
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
unsigned int FUZ_rand(unsigned int *src)
static void locateBuffDiff(const void *buff1, const void *buff2, size_t size, o_scenario_e o_scenario)
int main(int argc, const char **argv)
int basicTests(U32 seed, double compressibility)
static clock_t FUZ_GetClockSpan(clock_t clockStart)
#define COMPRESSIBLE_NOISE_LENGTH
#define DISPLAYUPDATE(l,...)
static void FUZ_writeLE32(void *dstVoidPtr, U32 value32)
int fuzzerTests(U32 seed, unsigned nbTests, unsigned startTest, double compressibility, U32 duration_s)
#define LZ4F_MAGIC_SKIPPABLE_START
static unsigned FUZ_highbit(U32 v32)
static void FUZ_fillCompressibleNoiseBuffer(void *buffer, size_t bufferSize, double proba, U32 *seed)
static clock_t g_clockTime
#define DISPLAYLEVEL(l,...)
size_t test_lz4f_decompression_wBuffers(const void *cSrc, size_t cSize, void *dst, size_t dstCapacity, o_scenario_e o_scenario, const void *srcRef, size_t decompressedSize, U64 crcOrig, U32 *const randState, LZ4F_dctx *const dCtx, U32 seed, U32 testNb, int findErrorPos)
int FUZ_usage(const char *programName)
static const U32 nbTestsDefault
size_t test_lz4f_decompression(const void *cSrc, size_t cSize, const void *srcRef, size_t decompressedSize, U64 crcOrig, U32 *const randState, LZ4F_dctx *const dCtx, U32 seed, U32 testNb, int findErrorPos)
#define FUZ_COMPRESSIBILITY_DEFAULT
static const clock_t refreshRate
RZ_API void Ht_() free(HtName_(Ht) *ht)
return memset(p, 0, total)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * malloc(size_t size)
void * calloc(size_t number, size_t size)
static static fork const void static count static fd const char const char static newpath char char char static envp time
static static fork const void static count static fd const char const char static newpath char char argv
static void struct sockaddr socklen_t static fromlen static backlog static fork char char char static envp int struct rusage static rusage struct utsname static buf struct sembuf unsigned
XXH_PUBLIC_API unsigned int XXH32(const void *input, size_t len, unsigned int seed)
XXH_PUBLIC_API XXH_errorcode XXH64_update(XXH64_state_t *state_in, const void *input, size_t len)
XXH_PUBLIC_API XXH_errorcode XXH64_reset(XXH64_state_t *statePtr, unsigned long long seed)
XXH_PUBLIC_API unsigned long long XXH64(const void *input, size_t len, unsigned long long seed)
XXH_PUBLIC_API unsigned long long XXH64_digest(const XXH64_state_t *state_in)
struct XXH64_state_s XXH64_state_t
#define LZ4_VERSION_STRING
const char char int inputSize
LZ4F_errorCode_t LZ4F_freeDecompressionContext(LZ4F_dctx *dctx)
size_t LZ4F_compressBegin(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_getBlockSize(unsigned blockSizeID)
size_t LZ4F_compressUpdate(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_compressOptions_t *compressOptionsPtr)
int LZ4F_compressionLevel_max(void)
LZ4F_CDict * LZ4F_createCDict(const void *dictBuffer, size_t dictSize)
size_t LZ4F_compressFrameBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_flush(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
size_t LZ4F_compressFrame_usingCDict(LZ4F_cctx *cctx, void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_CDict *cdict, const LZ4F_preferences_t *preferencesPtr)
size_t LZ4F_decompress_usingDict(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const void *dict, size_t dictSize, const LZ4F_decompressOptions_t *decompressOptionsPtr)
size_t LZ4F_decompress(LZ4F_dctx *dctx, void *dstBuffer, size_t *dstSizePtr, const void *srcBuffer, size_t *srcSizePtr, const LZ4F_decompressOptions_t *decompressOptionsPtr)
size_t LZ4F_compressBound(size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
LZ4F_errorCode_t LZ4F_freeCompressionContext(LZ4F_cctx *cctxPtr)
unsigned LZ4F_isError(LZ4F_errorCode_t code)
LZ4F_errorCode_t LZ4F_getFrameInfo(LZ4F_dctx *dctx, LZ4F_frameInfo_t *frameInfoPtr, const void *srcBuffer, size_t *srcSizePtr)
LZ4F_errorCode_t LZ4F_createDecompressionContext(LZ4F_dctx **LZ4F_decompressionContextPtr, unsigned versionNumber)
void LZ4F_resetDecompressionContext(LZ4F_dctx *dctx)
size_t LZ4F_compressFrame(void *dstBuffer, size_t dstCapacity, const void *srcBuffer, size_t srcSize, const LZ4F_preferences_t *preferencesPtr)
LZ4F_errorCode_t LZ4F_createCompressionContext(LZ4F_cctx **LZ4F_compressionContextPtr, unsigned version)
LZ4F_errorCodes LZ4F_getErrorCode(size_t functionResult)
void LZ4F_freeCDict(LZ4F_CDict *cdict)
const char * LZ4F_getErrorName(LZ4F_errorCode_t code)
size_t LZ4F_compressEnd(LZ4F_cctx *cctxPtr, void *dstBuffer, size_t dstCapacity, const LZ4F_compressOptions_t *compressOptionsPtr)
size_t LZ4F_headerSize(const void *src, size_t srcSize)
#define LZ4F_MIN_SIZE_TO_KNOW_HEADER_LENGTH
@ LZ4F_contentChecksumEnabled
@ LZ4F_blockChecksumEnabled
assert(limit<=UINT32_MAX/2)
LZ4F_contentChecksum_t contentChecksumFlag
unsigned long long contentSize
LZ4F_blockChecksum_t blockChecksumFlag
LZ4F_blockMode_t blockMode
LZ4F_blockSizeID_t blockSizeID
LZ4F_frameInfo_t frameInfo