From: Yann Collet Date: Thu, 19 Dec 2024 15:38:14 +0000 (-0800) Subject: added a test for ZSTD_compressSequencesAndLiterals X-Git-Tag: v1.5.7^2~48^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a80f55f47d7d4076c19a000459b88e28e8c95eee;p=thirdparty%2Fzstd.git added a test for ZSTD_compressSequencesAndLiterals checks that srcSize is present in the frame header and bounds the window size. --- diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 4901376ff..7907dbfad 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -3880,7 +3880,7 @@ static int basicUnitTests(U32 const seed, double compressibility) DISPLAYLEVEL(3, "test%3i : ZSTD_compressSequencesAndLiterals : ", testNb++); { - const size_t srcSize = 500 KB; + const size_t srcSize = 497000; const BYTE* const src = (BYTE*)CNBuffer; BYTE* const dst = (BYTE*)compressedBuffer; const size_t dstCapacity = ZSTD_compressBound(srcSize); @@ -3929,6 +3929,21 @@ static int basicUnitTests(U32 const seed, double compressibility) goto _output_error; } } + { ZSTD_frameHeader zfh; + size_t const zfhStatus = ZSTD_getFrameHeader(&zfh, dst, compressedSize); + if (zfhStatus != 0) { + DISPLAY("Error reading frame header\n"); + goto _output_error; + } + if (zfh.frameContentSize != srcSize) { + DISPLAY("Error: ZSTD_compressSequencesAndLiterals() did not report srcSize in the frame header\n"); + goto _output_error; + } + if (zfh.windowSize > srcSize) { + DISPLAY("Error: ZSTD_compressSequencesAndLiterals() did not resized window size to smaller contentSize\n"); + goto _output_error; + } + } { size_t const dSize = ZSTD_decompress(decompressBuffer, decompressSize, dst, compressedSize); if (ZSTD_isError(dSize)) { DISPLAY("Error during decompression of frame produced by ZSTD_compressSequencesAndLiterals()\n");