googleapis / googleapis/google-cloud-rust

RequestedRange::as_proto casts u64 to i64 without clamping

Open Beginner friendly
#6,691 0 comments 0 reactions 0 assignees View on GitHub
api: storage type: bug
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.

In `src/storage/src/storage/bidi/requested_range.rs`, `RequestedRange::as_proto` converts range offsets and lengths to protobuf fields using raw `as i64` casts:

https://github.com/googleapis/google-cloud-rust/blob/f02b42c2ac5720334cd2b5335824bd4166264527/src/storage/src/storage/bidi/requested_range.rs#L26-L40

For `ReadRange::offset(u64::MAX)`, `u64::MAX as i64` produces `read_offset: -1`. Additionally, computing `-(v as i64)` for `ReadRange::tail(1 << 63)` overflows and panics in debug builds.

Contributor guide

Open the contributing guide

Research direction

Start in src/storage/src/storage/bidi/requested_range.rs at RequestedRange::as_proto and inspect how offsets and lengths become protobuf fields. Reproduce the ReadRange::offset(u64::MAX) and ReadRange::tail(1 << 63) cases, then add coverage showing conversions are safely bounded and do not panic.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.