fix(image): parallel Range-fetch guards + splitRanges test#17
Merged
Conversation
fetchRange checked only status 206, then blindly copied the body at the chunk offset. A misbehaving edge (short 206, or a 206 whose actual span differs from the request) would land bytes at the wrong offset or leave a zero hole, surfaced only after verifyDigest re-hashes the whole multi-GB file three times. Add the Content-Range prefix check and the n==want short-body guard (cocoon parity) so a bad range fails fast and precisely. Extract splitRanges and unit-test the contiguous / non-overlapping / covers-[0,size) invariant.
Bumps cocoon to master (pseudo-version) which exports the shared range helpers, and drops the local splitRanges + inline response guards; the split-contract test moved to cocoon utils with the implementation. cloudimg.New grew a pullConns parameter — pass 0 for its default.
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.
Adversarial-review finding on tonight's parallel OCI blob pull (mirrors the cocoon parallel-download guards).
Fix
io.Copy'd the body at the chunk offset with no length or range check. A misbehaving CDN edge (short 206 body, or a 206 whose actual range differs from the request) would land bytes at the wrong offset / leave a zero hole. It's backstopped byverifyDigest(digest mismatch), but only after re-hashing the whole multi-GB file three times — an opaque, expensive failure. Add the Content-Range prefix check and the n==want short-body guard so a bad range fails fast and precisely.fetchParalleland unit-tested (contiguous, non-overlapping, covers [0,size), ≤n chunks) so the disjoint-offset invariant that makes concurrent pwrite safe can't silently regress.(pullConns is a const 8 here, so the unbounded-conn footgun flagged in cocoon does not apply.)
Verification
GOWORK=off build/test/
-racegreen; lint 0 issues both GOOS; fmt-check clean.