xgbtxy opened a new pull request, #3773:
URL: https://github.com/apache/iceberg-rust/pull/3773

   ## Which issue does this PR close?
   
   - None (standalone bug fix discovered during Puffin reader audit).
   
   ## What changes are included in this PR?
   
   Validate `BlobMetadata` byte ranges in `PuffinReader::blob` before calling 
`FileRead::read`:
   
   - Reject `offset < FileMetadata::MAGIC_LENGTH` (4 bytes) so a blob cannot 
overlap the Puffin file header magic.
   - Replace unchecked `start + blob_metadata.length` with `checked_add` to 
prevent arithmetic overflow panics in debug builds and wrap-around (`end < 
start`, panicking in `MemoryFileRead` or underflowing in `LocalFsFileRead`) in 
release builds.
   - Reject `end > self.file_length` up front with `ErrorKind::DataInvalid`, 
matching the bounds check in `FileMetadata::read`.
   
   ## Are these changes tested?
   
   Yes. Added unit tests in `crates/iceberg/src/puffin/reader.rs` covering 
`u64` overflow/wrap-around ranges, ranges exceeding `file_length`, and offsets 
overlapping the 4-byte Puffin header magic, and ran the `puffin` test suite 
(`cargo test -p iceberg --lib puffin`).
   
   ## AI Disclosure
   
   AI-assisted tooling was used to audit `crates/iceberg/src/puffin/reader.rs`, 
draft the fix and unit tests, and run local verification.
   
   Areas of uncertainty / assumptions:
   - Assumes every valid Puffin blob starts at or after byte offset 4 
(`FileMetadata::MAGIC_LENGTH`) per the Puffin file structure spec, and that no 
caller intentionally passes a synthetic `BlobMetadata` with `offset < 4` to 
read header magic bytes.
   - Local verification ran on Windows with `cargo +stable` tests/clippy and 
`cargo +nightly fmt -- --check`; full workspace Linux CI and `public-api` 
checks will run on GitHub Actions.
   


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to