Added frame content size test within fuzzer
This commit is contained in:
@@ -1033,7 +1033,7 @@ size_t ZSTD_decompress(void* dst, size_t maxDstSize, const void* src, size_t src
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ******************************
|
/*_******************************
|
||||||
* Streaming Decompression API
|
* Streaming Decompression API
|
||||||
********************************/
|
********************************/
|
||||||
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx)
|
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx)
|
||||||
|
|||||||
+8
-2
@@ -513,8 +513,7 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
|
|||||||
CHECK(ZSTD_isError(cSize), "ZSTD_compressCCtx failed");
|
CHECK(ZSTD_isError(cSize), "ZSTD_compressCCtx failed");
|
||||||
|
|
||||||
/* compression failure test : too small dest buffer */
|
/* compression failure test : too small dest buffer */
|
||||||
if (cSize > 3)
|
if (cSize > 3) {
|
||||||
{
|
|
||||||
const size_t missing = (FUZ_rand(&lseed) % (cSize-2)) + 1; /* no problem, as cSize > 4 (frameHeaderSizer) */
|
const size_t missing = (FUZ_rand(&lseed) % (cSize-2)) + 1; /* no problem, as cSize > 4 (frameHeaderSizer) */
|
||||||
const size_t tooSmallSize = cSize - missing;
|
const size_t tooSmallSize = cSize - missing;
|
||||||
static const U32 endMark = 0x4DC2B1A9;
|
static const U32 endMark = 0x4DC2B1A9;
|
||||||
@@ -526,6 +525,13 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
|
|||||||
CHECK(endCheck != endMark, "ZSTD_compressCCtx : dst buffer overflow");
|
CHECK(endCheck != endMark, "ZSTD_compressCCtx : dst buffer overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* decompression header test */
|
||||||
|
{ ZSTD_frameParams dParams;
|
||||||
|
size_t const check = ZSTD_getFrameParams(&dParams, cBuffer, cSize);
|
||||||
|
CHECK(ZSTD_isError(check), "Frame Parameters extraction failed");
|
||||||
|
CHECK(dParams.frameContentSize != sampleSize, "Frame content size incorrect");
|
||||||
|
}
|
||||||
|
|
||||||
/* successfull decompression tests*/
|
/* successfull decompression tests*/
|
||||||
dSupSize = (FUZ_rand(&lseed) & 1) ? 0 : (FUZ_rand(&lseed) & 31) + 1;
|
dSupSize = (FUZ_rand(&lseed) & 1) ? 0 : (FUZ_rand(&lseed) & 31) + 1;
|
||||||
dSize = ZSTD_decompress(dstBuffer, sampleSize + dSupSize, cBuffer, cSize);
|
dSize = ZSTD_decompress(dstBuffer, sampleSize + dSupSize, cBuffer, cSize);
|
||||||
|
|||||||
Reference in New Issue
Block a user