googleapis / googleapis/google-cloud-rust
Integer overflow in HTTP Range header calculation for large segment limits
- Dominant language
- Rust
- Stars
- 955
- Forks
- 144
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 279
Description
Unconfirmed. This is the result of a search with Claude, may be a false positive.
When constructing the HTTP `Range` header in `read_object.rs`, `model_ext.rs` clamps offset and limit independently:
https://github.com/googleapis/google-cloud-rust/blob/f02b42c2ac5720334cd2b5335824bd4166264527/src/storage/src/storage/model_ext.rs#L287-L306
Then, in `read_object.rs`:
https://github.com/googleapis/google-cloud-rust/blob/f02b42c2ac5720334cd2b5335824bd4166264527/src/storage/src/storage/read_object.rs#L634
The expression `format!("bytes={o}-{e}", e = o + l - 1)` computes `o + l - 1` without checked or saturating arithmetic. For requests like `ReadRange::segment(1000, u64::MAX)`, `o + l` overflows, causing a panic in debug builds and integer wraparound in release builds.
Contributor guide
Research direction
Start by reading the offset and limit handling in src/storage/src/storage/model_ext.rs and the Range header construction in src/storage/src/storage/read_object.rs. Reproduce the issue with ReadRange::segment(1000, u64::MAX), then verify that large segment limits no longer overflow and that the resulting HTTP Range header remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100