Repository navigation
fix(ipc): validate block lengths before allocation - #11012
KHARSHAVARDHAN-eng wants to merge 1 commit into
Conversation
| let body_len = block.bodyLength().to_usize().unwrap(); | ||
| let metadata_len = block.metaDataLength().to_usize().unwrap(); | ||
| let total_len = body_len.checked_add(metadata_len).unwrap(); | ||
| let offset = u64::try_from(block.offset()) |
There was a problem hiding this comment.
nit: might be worth placing all the parsing Errors into a anon function that takes in a string. either way otherwise this makes sense 👍
| ArrowError::ParseError("Block body length + metadata length overflowed usize".to_string()) | ||
| })?; | ||
|
|
||
| let file_len = reader.seek(SeekFrom::End(0))?; |
There was a problem hiding this comment.
we probably should pass in the file length to the function, instead of re-seeking for every block read
b94fc60 to
a4921f1
Compare
|
Thanks for the review! I’ve addressed Jeffrey’s suggestion by calculating the file length once and passing it through to read_block, avoiding repeated end-of-file seeks. The changes have been verified with formatting, clippy, and the full arrow-ipc test suite. Ready for review. |
|
run benchmark ipc_reader |
|
🤖 Arrow criterion benchmark running (GKE) | trigger CPU Details (lscpu)Comparing fix-ipc-block-length-allocation (a4921f1) to b06b9c1 (merge-base) diff Run configurationrun benchmark ipc_readerBENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental,object_store --bench ipc_reader File an issue against this benchmark runner |
|
🤖 Arrow criterion benchmark completed (GKE) | trigger Instance: Comparing fix-ipc-block-length-allocation (a4921f1) to b06b9c1 (merge-base) diff Run configurationrun benchmark ipc_readerCPU Details (lscpu)Details
Resource Usagebase (merge-base)
branch
File an issue against this benchmark runner |
| let mut reader = match FileReaderBuilder::new().build(std::io::Cursor::new(file)) { | ||
| Ok(reader) => reader, | ||
| Err(err) => { | ||
| assert!( | ||
| matches!(err, ArrowError::ParseError(_)), | ||
| "expected ParseError for block ({body_length}, {meta_length}, {offset}): {err}" | ||
| ); | ||
| continue; |
There was a problem hiding this comment.
we shouldnt have this approach in tests; it makes it unclear which test case here is expected to pass or fail this specific assertion. can we split the cases up to be clear which should successfully build a reader and which should fail
|
This PR looks abandoned and I don't see any evidence of human engagement. I am going to close it for now; Please reopen and respond to reviewer comments if you want to proceed with this |
Closes #10921
Summary
Validation
cargo fmt --checkcargo clippy -p arrow-ipc --all-targets -- -D warningscargo test -p arrow-ipcgit diff --check