Prevent fuzz testers from combining large dicts with high clevel
This commit is contained in:
parent
7e35b352c6
commit
f5e50519e0
@ -66,6 +66,7 @@ static clock_t g_displayClock = 0;
|
|||||||
* Fuzzer functions
|
* Fuzzer functions
|
||||||
*********************************************************/
|
*********************************************************/
|
||||||
#define MIN(a,b) ((a)<(b)?(a):(b))
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
||||||
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
||||||
|
|
||||||
static clock_t FUZ_clockSpan(clock_t cStart)
|
static clock_t FUZ_clockSpan(clock_t cStart)
|
||||||
{
|
{
|
||||||
@ -799,11 +800,12 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, U32 const maxD
|
|||||||
/*===== Streaming compression test, scattered segments and dictionary =====*/
|
/*===== Streaming compression test, scattered segments and dictionary =====*/
|
||||||
|
|
||||||
{ U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
{ U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
int const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (testLog/3))) + 1;
|
U32 const dictLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
|
int const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (MAX(testLog, dictLog)/3))) + 1;
|
||||||
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
||||||
if (maxTestSize >= dstBufferSize) maxTestSize = dstBufferSize-1;
|
if (maxTestSize >= dstBufferSize) maxTestSize = dstBufferSize-1;
|
||||||
|
|
||||||
dictSize = FUZ_randomLength(&lseed, maxSampleLog); /* needed also for decompression */
|
dictSize = FUZ_rLogLength(&lseed, dictLog); /* needed also for decompression */
|
||||||
dict = srcBuffer + (FUZ_rand(&lseed) % (srcBufferSize - dictSize));
|
dict = srcBuffer + (FUZ_rand(&lseed) % (srcBufferSize - dictSize));
|
||||||
|
|
||||||
if (FUZ_rand(&lseed) & 0xF) {
|
if (FUZ_rand(&lseed) & 0xF) {
|
||||||
|
@ -645,11 +645,12 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compres
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
U32 const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (testLog/3))) + 1;
|
U32 const dictLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
|
U32 const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (MAX(testLog, dictLog)/3))) + 1;
|
||||||
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
||||||
oldTestLog = testLog;
|
oldTestLog = testLog;
|
||||||
/* random dictionary selection */
|
/* random dictionary selection */
|
||||||
dictSize = ((FUZ_rand(&lseed)&63)==1) ? FUZ_randomLength(&lseed, maxSampleLog) : 0;
|
dictSize = ((FUZ_rand(&lseed)&63)==1) ? FUZ_rLogLength(&lseed, dictLog) : 0;
|
||||||
{ size_t const dictStart = FUZ_rand(&lseed) % (srcBufferSize - dictSize);
|
{ size_t const dictStart = FUZ_rand(&lseed) % (srcBufferSize - dictSize);
|
||||||
dict = srcBuffer + dictStart;
|
dict = srcBuffer + dictStart;
|
||||||
}
|
}
|
||||||
@ -886,11 +887,12 @@ static int fuzzerTests_MT(U32 seed, U32 nbTests, unsigned startTest, double comp
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
U32 const testLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
U32 const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (testLog/3))) + 1;
|
U32 const dictLog = FUZ_rand(&lseed) % maxSrcLog;
|
||||||
|
U32 const cLevel = (FUZ_rand(&lseed) % (ZSTD_maxCLevel() - (MAX(testLog, dictLog)/3))) + 1;
|
||||||
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
maxTestSize = FUZ_rLogLength(&lseed, testLog);
|
||||||
oldTestLog = testLog;
|
oldTestLog = testLog;
|
||||||
/* random dictionary selection */
|
/* random dictionary selection */
|
||||||
dictSize = ((FUZ_rand(&lseed)&63)==1) ? FUZ_randomLength(&lseed, maxSampleLog) : 0;
|
dictSize = ((FUZ_rand(&lseed)&63)==1) ? FUZ_rLogLength(&lseed, dictLog) : 0;
|
||||||
{ size_t const dictStart = FUZ_rand(&lseed) % (srcBufferSize - dictSize);
|
{ size_t const dictStart = FUZ_rand(&lseed) % (srcBufferSize - dictSize);
|
||||||
dict = srcBuffer + dictStart;
|
dict = srcBuffer + dictStart;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user