mirror of
https://github.com/facebook/zstd.git
synced 2025-08-01 09:47:01 +03:00
fixed T36302429
This commit is contained in:
@ -1742,15 +1742,17 @@ static int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, U32 const maxD
|
||||
CHECK(ZSTD_isError(cSize), "ZSTD_compressCCtx failed : %s", ZSTD_getErrorName(cSize));
|
||||
|
||||
/* compression failure test : too small dest buffer */
|
||||
if (cSize > 3) {
|
||||
const size_t missing = (FUZ_rand(&lseed) % (cSize-2)) + 1; /* no problem, as cSize > 4 (frameHeaderSizer) */
|
||||
assert(cSize > 3);
|
||||
{ const size_t missing = (FUZ_rand(&lseed) % (cSize-2)) + 1;
|
||||
const size_t tooSmallSize = cSize - missing;
|
||||
const U32 endMark = 0x4DC2B1A9;
|
||||
memcpy(dstBuffer+tooSmallSize, &endMark, 4);
|
||||
DISPLAYLEVEL(5, "fuzzer t%u: compress into too small buffer of size %u (missing %u bytes) \n",
|
||||
testNb, (unsigned)tooSmallSize, (unsigned)missing);
|
||||
{ size_t const errorCode = ZSTD_compressCCtx(ctx, dstBuffer, tooSmallSize, sampleBuffer, sampleSize, cLevel);
|
||||
CHECK(!ZSTD_isError(errorCode), "ZSTD_compressCCtx should have failed ! (buffer too small : %u < %u)", (U32)tooSmallSize, (U32)cSize); }
|
||||
{ U32 endCheck; memcpy(&endCheck, dstBuffer+tooSmallSize, 4);
|
||||
CHECK(endCheck != endMark, "ZSTD_compressCCtx : dst buffer overflow"); }
|
||||
CHECK(endCheck != endMark, "ZSTD_compressCCtx : dst buffer overflow (check.%08X != %08X.mark)", endCheck, endMark); }
|
||||
} }
|
||||
|
||||
/* frame header decompression test */
|
||||
|
Reference in New Issue
Block a user