Repository navigation
fix(fleet-dispatch): checked arithmetic on peer-declared chunk size in dechunked_len (#6512) - #8069
Conversation
…n dechunked_len (#6512)
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Salvage comparison from the shepherd pass on duplicate PR #8004 (same change, "Fix #6512: checked arithmetic on peer-declared chunk size in fleet-dispatch", head queue/14068-6512-dispatch-dechunk-checked @ 61bfc4a). This PR (#8069) is the canonical landed version: ee35855 plus the salvaged probe test b3f74fd, merged 2026-11-10 (merge 8f27f04), which closed #6512. Diffing #8004's change against current main:
#8004 is being closed as superseded by this PR. Probe on current main: cargo test -p fleet-dispatch dechunked_len passes. — repo-worker-code, lane any-b (task 17253) |
What
dechunked_len(fleet-dispatch's chunked-response completeness checker) did raw arithmetic on the peer-declared chunk size:size + 2for the completeness guard and the slice index,total += sizefor the running total. For a chunk-size line namingusize::MAXorusize::MAX - 1that panics in debug builds and wraps in release builds, so the completeness verdict is computed from wrapped values (#6512; the #5579 rule — peer-declared sizes are never trusted).Fix
Production code, not just the test: every arithmetic step on the declared size is now checked.
size.checked_add(2)— a size whose chunk + trailing CRLF cannot fit ausizereads as "not complete" (None).total.checked_add(size)— the running total is checked too.A chunk-size line that cannot describe a body within the buffered remainder is therefore "not complete" in every profile — never a panic, never a completed body computed from wrapped values. Signature and caller contract unchanged;
dechunk(already guarded) untouched.Test
The characterization test salvaged from PR #7524 pinned the old overflow-panic ("must overflow-panic on usize::MAX until #6512 lands") and failed deterministically in the release-profile Nix check phase, blocking every generation build from
main. It is updated deliberately, as its own comment instructed, intodechunked_len_huge_chunk_size_is_not_complete, pinning:usize::MAX,usize::MAX - 1) →Nonevia direct calls (a panic would fail the test);None;None;Verified on the laptop, real crate:
cargo test -p fleet-dispatch(debug): 11 passed, 0 failedcargo test --release -p fleet-dispatch(release): 11 passed, 0 failedFixes #6512. This also unblocks the #7991 deploy: fork PR opencode#2237 and pin bump #8067 are merged, but no generation could build from
mainwhile this check-phase failure stood.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.