Mola-maker opened a new pull request, #12404:
URL: https://github.com/apache/arrow-rs/pull/12404

   Closes #10921.
   
   `read_block` sized its buffer from the footer's `Block` before reading it. A 
file whose footer declares a body length of 44 TiB reaches 
`MutableBuffer::from_len_zeroed` with that size, which aborts the process. 
`read_exact` would have returned `UnexpectedEof` had the allocation been 
bounded.
   
   `read_block` now validates the block before allocating. Negative lengths are 
rejected. Overflowing length arithmetic is rejected. A block whose offset plus 
length runs past the end of the file is rejected. All three cases return 
`ArrowError::IpcError`.
   
   The file length is measured once when the reader is built, and passed to 
every block read. No seek happens per block.
   
   This is the same approach as #11012, which was closed as abandoned. The 
`StreamReader` path is not covered here. geoHeil's vendored patch 
(telekom/sutura#1930) covers that path too, and he said it is fine to copy and 
refine it from there. That part can follow separately.
   
   ## Are these changes tested?
   
   Yes. New test 
`reader::tests::test_file_reader_rejects_block_extending_past_file`. It builds 
a valid file, then corrupts the first record-batch block's `bodyLength` two 
ways. A negative length returns `IpcError`. A declared length of 0x280000000240 
(~44 TiB) on a ~1 KiB file returns `IpcError` with "extends past the end of the 
file".
   
   Before the fix, the same input aborts the process instead of returning an 
error (see #10921). After the fix, the test passes. Full `arrow-ipc` lib suite: 
151 passed, 0 failed. `cargo fmt --check` and `cargo clippy --all-targets 
--all-features -D warnings` are clean.
   
   AI usage disclosure: this PR was developed and tested with AI assistance 
(harness: Claude; model: Claude Opus 5.5).
   


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