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

[nocommit] Repro for zstd_decompress.c assert violation #73

Closed
wants to merge 1 commit into from

Conversation

embg
Copy link
Owner

@embg embg commented Mar 18, 2024

This is unrelated to magicless fuzzing -- the code in this PR uses the standard format decoder. I'm not sure yet if this is happening on valid frames or only invalid frames.

To run the fuzzer:

cd ~/repos/zstd/tests/fuzz
python3 ./fuzz.py build stream_decompress --enable-fuzzer --enable-asan --debug 1
python3 ./fuzz.py libfuzzer stream_decompress

The fuzzer should trigger the assert:

stream_decompress: /home/embg/repos/zstd/lib//decompress/zstd_decompress.c:1346: size_t ZSTD_decompressContinue(ZSTD_DCtx *, void *, size_t, const void *, size_t): Assertion `srcSize <= dctx->expected' failed.

Here is the failing assert: https://github.com/facebook/zstd/blob/0fcdc62c2d13f4d978ecba703c7d381ce97c97f1/lib/decompress/zstd_decompress.c#L1346

The assert was added in this PR: facebook#1947

@embg embg force-pushed the assert_failure branch 2 times, most recently from 00dc6c7 to 0c028a5 Compare March 18, 2024 00:46
@embg embg changed the title [nocommit] Repro for assert failure in zstd_decompress.c [nocommit] Repro for ZSTD_compressBound violation in zstd_decompress.c Mar 18, 2024
@embg embg changed the title [nocommit] Repro for ZSTD_compressBound violation in zstd_decompress.c [nocommit] Repro for ZSTD_compressBound violation Mar 18, 2024
@embg embg changed the title [nocommit] Repro for ZSTD_compressBound violation [nocommit] Repro for zstd_decompress.c assert violation Mar 18, 2024
// Fuzzer is unable to trigger the assert if this goto is uncommented
// goto error;
}
ZSTD_decompressStream(dstream, &realOut, &in);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call is UB when ZSTD_isError(ret1).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, then there is no problem. Thanks for looking.

@embg embg closed this Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants