From 7b294caf461a15d74e64389bde16d5c33fc3d0c8 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 23 Dec 2024 19:43:17 -0800 Subject: [PATCH] add one valid test case ZSTD_compressSequencesAndLiterals() may return a specific error code when data to compress is non-compressible. --- tests/fuzz/sequence_compression_api.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/fuzz/sequence_compression_api.c b/tests/fuzz/sequence_compression_api.c index 32710afb93..21b6ac84e9 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");