Repository navigation
chunkers: range-check size exponents, reject negative fixed header_size - #10628
Merged
ThomasWaldmann merged 1 commit intoNov 14, 2026
Merged
Conversation
The chunkers compute min/max chunk sizes as 1 << chunk_min_exp and 1 << chunk_max_exp with C int operands, so their parameter checks only work on well-defined shift results. They now raise ValueError unless both exponents are in 0..30, before any shift (ChunkerBase._setup_common and the buzhash / buzhash64 constructors, which check the window fit first). ChunkerParams now also rejects a negative header_size for the fixed chunker, so only valid chunker params get stored in archive metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10628 +/- ##
=======================================
Coverage 89.45% 89.45%
=======================================
Files 105 105
Lines 20339 20341 +2
Branches 3198 3199 +1
=======================================
+ Hits 18194 18196 +2
- Misses 1489 1491 +2
+ Partials 656 654 -2 ☔ View full report in Codecov by Harness. |
Member
Author
|
@m3nu ^ |
Contributor
|
Verified locally and works as intended. All 5 tests fail pre-fix, but raise as intended after. |
ThomasWaldmann
added a commit
that referenced
this pull request
Nov 14, 2026
Backport of the master change from #10628. Chunker.__cinit__ computes the min/max chunk sizes as 1 << chunk_min_exp and 1 << chunk_max_exp with C int operands, so its parameter checks only work on well-defined shift results. It now raises ValueError unless both exponents are in 0..30, before any shift. ChunkerParams now also rejects a negative header_size for the fixed chunker, so only valid chunker params get stored in archive metadata. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #10603 (found while reviewing its 1.4-maint backport #10619).
Changes
1 << chunk_min_exp/1 << chunk_max_expwith Cintoperands, so their parameter checks only work on well-defined shift results. A new_check_size_exps()(inchunkers/base.pxd) raisesValueErrorunless both exponents are in0..30. It runs before any shift: inChunkerBase._setup_common(FastCDC, PHTE/AES chunkers) and in the buzhash / buzhash64 constructors, which do their window-fit check before calling_setup_common.ChunkerParamsrejects a negativeheader_sizefor thefixedchunker, so only valid chunker params get stored in archive metadata.ChunkerParamsalready limits the buzhash/fastcdc exponents to 6..23, so this only affects direct constructor calls; cut points are unchanged.Testing
test_chunkers_reject_invalid_params(exponent 40 for fastcdc, buzhash, buzhash64; negative exponent for fastcdc) andtest_invalid_chunkerparams(fixed,4096,-1). All 5 fail without the fix and pass with it.testsuite/chunkers/,parseformat_test.pyand the archiver-k "chunker or rechunk or recreate or benchmark"tests pass;python -Ostill gets theValueError.🤖 Generated with Claude Code