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

   # Which issue does this PR close?
   
   No tracking issue; found during core maintenance.
   
   # Rationale for this change
   
   `BytesContentRange` is populated from the `Content-Range` response header, 
which is untrusted input. Two arithmetic expressions in `len()` and `range()` 
overflow at `u64::MAX`, panicking in debug builds and wrapping to a wrong or 
empty result in release builds. The parser also accepted `last-pos` values that 
are not less than `complete-length`, which RFC 9110 Section 14.4 defines as 
invalid.
   
   # What changes are included in this PR?
   
   - `len()` uses `checked_add(1)` and returns `None` when the inclusive length 
cannot be represented.
   - `range()` uses `checked_add(1)` and returns `None` when the exclusive end 
cannot be represented.
   - `from_str()` rejects a known `complete-length` that is less than or equal 
to `last-pos`, while keeping `*/<size>` unchanged.
   - Add unit tests for overflow, RFC 9110 size validation, valid boundaries, 
and parsing the maximum representable range.
   
   # Are there any user-facing changes?
   
   `BytesContentRange::len()` and `range()` now return `None` instead of 
panicking or wrapping for ranges ending at `u64::MAX`. Malformed 
`Content-Range` headers with `complete-length <= last-pos` now fail with 
`ErrorKind::Unexpected` instead of being accepted.
   
   # Breaking changes
   
   # AI Usage Statement
   
   - Harness: pi coding agent
   - Model: group/deepseek
   - Effort: max
   - Role: Investigated the overflow and RFC 9110 validation behavior, 
implemented the fix and unit tests, and ran formatting, clippy, and 
`opendal-core` tests. Validation is limited to unit tests for the core parser; 
no live storage service is involved.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to