From: Yonatan Komornik <11005061+yoniko@users.noreply.github.com> Date: Mon, 18 Mar 2024 22:36:40 +0000 (-0700) Subject: Fix bugs in simple decompression fuzzer (#3978) X-Git-Tag: v1.5.6^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6a0052a409e2604bd40354b76b86272b712edd7d;p=thirdparty%2Fzstd.git Fix bugs in simple decompression fuzzer (#3978) Fixes 2 issue in `simple_decompress.c`: 1. Wrong type used for storing the results of `ZSTD_findDecompressedSize` resulting in never matching to `ZSTD_CONTENTSIZE_ERROR` or `ZSTD_CONTENTSIZE_UNKNOWN`. 2. Experimental API is used (`ZSTD_findDecompressedSize`) without defining `ZSTD_STATIC_LINKING_ONLY`. --- diff --git a/tests/fuzz/simple_decompress.c b/tests/fuzz/simple_decompress.c index 0ee61902c..ab4697ff1 100644 --- a/tests/fuzz/simple_decompress.c +++ b/tests/fuzz/simple_decompress.c @@ -16,6 +16,9 @@ #include #include #include + +#define ZSTD_STATIC_LINKING_ONLY + #include "fuzz_helpers.h" #include "zstd.h" #include "fuzz_data_producer.h" @@ -40,7 +43,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *src, size_t size) size_t const dSize = ZSTD_decompressDCtx(dctx, rBuf, bufSize, src, size); if (!ZSTD_isError(dSize)) { /* If decompression was successful, the content size from the frame header(s) should be valid. */ - size_t const expectedSize = ZSTD_findDecompressedSize(src, size); + unsigned long long const expectedSize = ZSTD_findDecompressedSize(src, size); FUZZ_ASSERT(expectedSize != ZSTD_CONTENTSIZE_ERROR); FUZZ_ASSERT(expectedSize == ZSTD_CONTENTSIZE_UNKNOWN || expectedSize == dSize); }