patrickswedish opened a new pull request, #11723:
URL: https://github.com/apache/arrow-rs/pull/11723
# Which issue does this PR close?
- Closes #11690
# Rationale for this change
In `ParquetMetaDataPushDecoder::try_decode`, the start of metadata was
calculated without bounds checking `metadata_len` against `file_len`:
```rust
let metadata_len: u64 = footer_tail.metadata_length() as u64;
let metadata_start = file_len - footer_len - metadata_len;
```
If a corrupted or truncated footer claims a metadata length such that
`file_len < footer_len + metadata_len`, this underflows and panics (`attempt to
subtract with overflow` in debug, slice panic in release).
# What changes are included in this PR?
- Adds an explicit check in `DecodeState::ReadingMetadata` verifying that
`file_len >= footer_len + metadata_len`.
- Returns `Err(eof_err!("Parquet file too small. Size is {} but need {}",
file_len, footer_len + metadata_len))` matching
`ParquetMetaDataReader::parse_and_finish`.
- Adds regression unit test `test_metadata_length_exceeds_file_size`.
# Are these changes tested?
Yes, added unit test `test_metadata_length_exceeds_file_size` in
`push_decoder.rs` asserting the structured `EOF` error.
# Are there any significant user-facing changes?
No breaking changes. Push decoder returns a structured `ParquetError::EOF`
instead of panicking on malformed inputs.
--
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]