[BUG] Compare the curl seek offset before narrowing it to size_t - #4630
Open
mateenali66 wants to merge 2 commits into
Open
mateenali66 wants to merge 2 commits into
mateenali66 wants to merge 2 commits into
Conversation
HttpOperation::SeekCallback narrowed the curl_off_t offset to size_t before its range check, so on a build where size_t is 32 bits an offset above the size_t range wrapped back inside the body and the callback reported CURL_SEEKFUNC_OK for a position it had not moved to. Compare in curl_off_t, the type libcurl passes, and leave the narrowing to after the check has passed. Negative offsets were already refused by the offset < 0 term, so only the upper bound changes. Follow-up to open-telemetry#4557. Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4630 +/- ##
==========================================
+ Coverage 86.52% 86.53% +0.02%
==========================================
Files 525 525
Lines 20475 20476 +1
==========================================
+ Hits 17713 17716 +3
+ Misses 2762 2760 -2
🚀 New features to boost your workflow:
|
lalitb
approved these changes
Sep 23, 2026
lalitb
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for following up on this!
This branch has not been deployed
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 #4557, from @lalitb's review comment.
Changes
HttpOperation::SeekCallbacknarrowed thecurl_off_toffset tosize_tbefore checking it against the body size. Wheresize_tis 32 bits, an offset past that range wraps back inside the body, so the callback answersCURL_SEEKFUNC_OKand the retried upload resumes from the wrong place. It now compares incurl_off_tand narrows after the check passes. Negatives were already refused by theoffset < 0term, so only the upper bound moves.@thc1006 and I both went looking for a case that reaches it and neither of us found one. libcurl derives the offset from its own position in the upload, and a 32 bit process can't hold a body big enough to get out of range. So this is the check having the wrong shape, not a live defect.
The test adds
UINT32_MAX + 4against a ten byte body. A 64 bit build refuses both forms, so it's only pinning the contract, and there's no 32 bit job in CI to tell them apart.28 of 28
curl_http_testpass locally on macOS arm64, Debug.The rewind path itself is still uncovered, for the reasons in #4557. @meastp has handed his reproducer back and that's a separate PR.
CHANGELOG.mdupdated for non-trivial changes