mirror of
https://github.com/facebook/zstd.git
synced 2025-09-02 15:41:31 +03:00
Fixed : decoder error on erroneous data
This commit is contained in:
@@ -596,18 +596,16 @@ int fuzzerTests(U32 seed, U32 nbTests, unsigned startTest, double compressibilit
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* decompress noisy source */
|
/* decompress noisy source */
|
||||||
{
|
{ U32 const noiseSrc = FUZ_rand(&lseed) % 5;
|
||||||
U32 noiseSrc = FUZ_rand(&lseed) % 5;
|
U32 const endMark = 0xA9B1C3D6;
|
||||||
const U32 endMark = 0xA9B1C3D6;
|
|
||||||
U32 endCheck;
|
|
||||||
srcBuffer = cNoiseBuffer[noiseSrc];
|
srcBuffer = cNoiseBuffer[noiseSrc];
|
||||||
memcpy(dstBuffer+sampleSize, &endMark, 4);
|
memcpy(dstBuffer+sampleSize, &endMark, 4);
|
||||||
errorCode = ZSTD_decompress(dstBuffer, sampleSize, cBuffer, cSize);
|
errorCode = ZSTD_decompress(dstBuffer, sampleSize, cBuffer, cSize);
|
||||||
/* result *may* be an unlikely success, but even then, it must strictly respect dest buffer boundaries */
|
/* result *may* be an unlikely success, but even then, it must strictly respect dest buffer boundaries */
|
||||||
CHECK((!ZSTD_isError(errorCode)) && (errorCode>sampleSize),
|
CHECK((!ZSTD_isError(errorCode)) && (errorCode>sampleSize),
|
||||||
"ZSTD_decompress on noisy src : result is too large : %u > %u (dst buffer)", (U32)errorCode, (U32)sampleSize);
|
"ZSTD_decompress on noisy src : result is too large : %u > %u (dst buffer)", (U32)errorCode, (U32)sampleSize);
|
||||||
memcpy(&endCheck, dstBuffer+sampleSize, 4);
|
{ U32 endCheck; memcpy(&endCheck, dstBuffer+sampleSize, 4);
|
||||||
CHECK(endMark!=endCheck, "ZSTD_decompress on noisy src : dst buffer overflow");
|
CHECK(endMark!=endCheck, "ZSTD_decompress on noisy src : dst buffer overflow"); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user