Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in simple decompression fuzzer #3978

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/fuzz/simple_decompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>

#define ZSTD_STATIC_LINKING_ONLY

#include "fuzz_helpers.h"
#include "zstd.h"
#include "fuzz_data_producer.h"
Expand All @@ -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);
}
Expand Down