Repository navigation
fuzz: check ZSTD_decompressBound() against declared sizes - #4832
ilyas-mallah wants to merge 1 commit into
Conversation
|
Hi @ilyas-mallah! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
@terrelln @Cyan4973 The open question in the description: should single-pass decoding reject Raw and RLE blocks above Block_Maximum_Size (#4669), instead of the bound counting them? I kept them decodable because rejecting changes which inputs decode. I can rework it to reject if you'd rather. Could one of you also approve the workflow run? No CI has run here or on #4833 and #4834, two small separate fixes ( |
ZSTD_decompressBound() a true upper boundZSTD_decompressBound() on overflow
ZSTD_decompressBound() on overflow|
@terrelln 6404711 already makes ZSTD_decompressBound() return an error on overflow and adds its own test, so I edited this PR down to what dev doesn't have. The library change and my unit test are gone. What's left is a zstd_frame_info fuzz check that the bound equals ZSTD_findDecompressedSize() when every frame declares its size, with legacy frames skipped. On dev before that commit the check fails on a two-frame input declaring 2^63 bytes each, where the bound was 0. I updated the title and description to match. |
terrelln
left a comment
There was a problem hiding this comment.
Thanks for the PR @ilyas-mallah! Sorry we ended up merging parallel fixes while this was outstanding.
|
This PR will need to be rebased before merging. |
Assert bound == ZSTD_findDecompressedSize() when every frame declares its size. Legacy frames are skipped through FUZZ_isCurrentFormat() since the frozen legacy decoders ignore the declared size.
7db4f8a to
d0bf1a1
Compare
What and why
The zstd_frame_info fuzz target now asserts that ZSTD_decompressBound() equals ZSTD_findDecompressedSize() when every frame declares its size. An overflowing total must be an error for both. The two functions answer the same question for such input, so the check catches either one drifting.
Legacy frames are skipped through a new helper, FUZZ_isCurrentFormat(), because the frozen legacy decoders ignore the declared size.
I ran zstd_frame_info with ASan and UBSan on a saved corpus for 120 s (3,684,427 runs), and it found no failure.
Checklist
Tools used
AI usage: Claude Code helped with the fuzzing runs and test builds. I traced the problem, wrote the check, and validated every change.