From: Yann Collet Date: Tue, 24 Dec 2024 03:43:17 +0000 (-0800) Subject: add one valid test case X-Git-Tag: v1.5.7^2~48^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b294caf461a15d74e64389bde16d5c33fc3d0c8;p=thirdparty%2Fzstd.git add one valid test case ZSTD_compressSequencesAndLiterals() may return a specific error code when data to compress is non-compressible. --- diff --git a/tests/fuzz/sequence_compression_api.c b/tests/fuzz/sequence_compression_api.c index 32710afb9..21b6ac84e 100644 --- a/tests/fuzz/sequence_compression_api.c +++ b/tests/fuzz/sequence_compression_api.c @@ -16,6 +16,7 @@ */ #define ZSTD_STATIC_LINKING_ONLY +#include "zstd_errors.h" #include #include @@ -275,7 +276,12 @@ static size_t roundTripTest_compressSequencesAndLiterals( return 0; } /* round-trip */ - FUZZ_ZASSERT(cSize); + if (ZSTD_isError(cSize)) { + ZSTD_ErrorCode err = ZSTD_getErrorCode(cSize); + /* this specific error might happen as a result of data being uncompressible */ + if (err != ZSTD_error_cannotProduce_uncompressedBlock) + FUZZ_ZASSERT(cSize); + } { size_t const dSize = ZSTD_decompressDCtx(dctx, result, resultCapacity, compressed, cSize); FUZZ_ZASSERT(dSize); FUZZ_ASSERT_MSG(dSize == srcSize, "Incorrect regenerated size");