Skip to content

Enforce literal buffer capacity contract - #4782

Merged
Cyan4973 merged 2 commits into
meta:devfrom
KSAGlory:fix/literal-capacity-contract
Nov 11, 2026
Merged

Cyan4973 merged 2 commits into
meta:devfrom
KSAGlory:fix/literal-capacity-contract

Conversation

@KSAGlory

Copy link
Copy Markdown
Contributor

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
…iterals()

Kernel callers read include/linux/zstd.h, which did not mention that
lit_capacity must be at least 8 bytes larger than lit_size. This is now
enforced, so a smaller capacity generates an error.
@Cyan4973 Cyan4973 self-assigned this Nov 11, 2026
@Cyan4973
Cyan4973 merged commit 4cf889e into meta:dev Nov 11, 2026
161 of 162 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants