Skip to content

[BUG] Compare the curl seek offset before narrowing it to size_t - #4630

Open
mateenali66 wants to merge 2 commits into
open-telemetry:mainfrom
mateenali66:fix/4557-seek-offset-compare
Open

mateenali66 wants to merge 2 commits into
open-telemetry:mainfrom
mateenali66:fix/4557-seek-offset-compare

Conversation

@mateenali66

@mateenali66 mateenali66 commented Sep 23, 2026

Copy link
Copy Markdown
Member

Follow-up to #4557, from @lalitb's review comment.

Changes

HttpOperation::SeekCallback narrowed the curl_off_t offset to size_t before checking it against the body size. Where size_t is 32 bits, an offset past that range wraps back inside the body, so the callback answers CURL_SEEKFUNC_OK and the retried upload resumes from the wrong place. It now compares in curl_off_t and narrows after the check passes. Negatives were already refused by the offset < 0 term, 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 + 4 against 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_test pass 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.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

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>
@mateenali66
mateenali66 requested a review from a team as a code owner September 23, 2026 00:12
Signed-off-by: Mateen Anjum <mateenali66@gmail.com>
@codecov

codecov Bot commented Sep 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.53%. Comparing base (463fb9f) to head (c06f061).

Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
ext/src/http/client/curl/http_operation_curl.cc 61.22% <100.00%> (+0.07%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lalitb lalitb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for following up on this!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants