Skip to content

Enforce literal buffer capacity contract - #4782

Open
KSAGlory wants to merge 1 commit into
facebook:devfrom
KSAGlory:fix/literal-capacity-contract
Open

KSAGlory wants to merge 1 commit into
facebook:devfrom
KSAGlory:fix/literal-capacity-contract

Conversation

@KSAGlory

Copy link
Copy Markdown

Summary

ZSTD_compressSequencesAndLiterals() documents that litCapacity must be at least 8 bytes larger than litSize, but the implementation only rejected capacities smaller than litSize.

This change enforces the full documented margin using an overflow-safe subtraction check. The regression coverage verifies that litSize + 7 is rejected with ZSTD_error_workSpace_tooSmall and that the exact litSize + 8 boundary succeeds.

Fixes #4779.

Testing

  • make -C tests fuzzer -j2
  • tests/fuzzer -v -i0 (347 unit checks passed)
  • make check -j2 (all tests completed successfully)
  • git diff --check

@meta-cla meta-cla Bot added the CLA Signed label Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant