You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "TennyZhuang (via GitHub)" <gi...@apache.org> on 2026/04/17 06:57:26 UTC

[PR] fix(core): prevent integer overflow in parse_into_range for u64::MAX bounds [opendal]

TennyZhuang opened a new pull request, #7397:
URL: https://github.com/apache/opendal/pull/7397

   # Which issue does this PR close?
   
   N/A — discovered via code review of boundary edge cases.
   
   # Rationale for this change
   
   `ReadContext::parse_into_range` converts `RangeBounds<u64>` into `Range<u64>` by adding 1 for `Bound::Excluded` start and `Bound::Included` end. When the bound value is `u64::MAX`, this causes:
   - **Debug builds**: panic due to integer overflow
   - **Release builds**: silent wraparound to 0, producing an incorrect range
   
   Both outcomes are wrong. Users can trigger this with ranges like `..=u64::MAX` or `(Bound::Excluded(u64::MAX), Bound::Unbounded)`.
   
   # What changes are included in this PR?
   
   - Replace `v + 1` with `v.checked_add(1)` for both `Bound::Excluded` start and `Bound::Included` end in `parse_into_range`
   - Return `ErrorKind::RangeNotSatisfied` on overflow instead of panicking or wrapping
   - Add two deterministic tests covering the `u64::MAX` edge cases
   
   # Are there any user-facing changes?
   
   Ranges that previously caused a panic (debug) or silent incorrect behavior (release) now return a clear `RangeNotSatisfied` error.
   
   # AI Usage Statement
   
   This PR was authored with assistance from Claude (Anthropic), used for code review, bug identification, fix implementation, and test writing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(core): prevent integer overflow in parse_into_range for u64::MAX bounds [opendal]

Posted by "asukaminato0721 (via GitHub)" <gi...@apache.org>.
asukaminato0721 merged PR #7397:
URL: https://github.com/apache/opendal/pull/7397


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org