ipc: slicing buffer should not panic on invalid slice
Maintainers usually reply within 1 day
A pull request for this has already been merged.
- #11881 by @wleeaf — merged
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 75/100
Research direction
Start with the linked slice operation in arrow-ipc/src/reader.rs and the failing test test_read_record_batch_buffer_out_of_bounds described in the issue. Trace how the IPC buffer offset and length reach slice_with_length, then run that test. Done means the invalid range returns an error and the test passes without a panic.
Written by the indexing model from the issue text.
Description
Describe the bug
slice_with_length could panic here as i dont believe offset & len are controlled/validated. we should ensure if an invalid slice is taken it should error, not panic
To Reproduce
#[test]
fn test_read_record_batch_buffer_out_of_bounds() {
use crate::r#gen::Message::{RecordBatch, RecordBatchArgs};
use flatbuffers::FlatBufferBuilder;
let schema = Arc::new(Schema::new(vec![Field::new("col", DataType::Int32, false)]));
let body = Buffer::from(vec![0u8; 8]);
let mut fbb = FlatBufferBuilder::new();
let nodes = fbb.create_vector(&[FieldNode::new(2, 0)]);
// Empty validity buffer followed by two Int32 values whose range exceeds the body.
let buffers = fbb.create_vector(&[crate::Buffer::new(0, 0), crate::Buffer::new(4, 8)]);
let batch = RecordBatch::create(
&mut fbb,
&RecordBatchArgs {
length: 2,
nodes: Some(nodes),
buffers: Some(buffers),
..Default::default()
},
);
fbb.finish_minimal(batch);
let batch = flatbuffers::root::<RecordBatch>(fbb.finished_data()).unwrap();
let result = read_record_batch(
&body,
batch,
schema,
&HashMap::new(),
None,
&MetadataVersion::V5,
);
assert!(
result.is_err(),
"invalid IPC buffer range must return an error"
);
}
- test generated by codex
output
---- reader::tests::test_read_record_batch_buffer_out_of_bounds stdout ----
thread 'reader::tests::test_read_record_batch_buffer_out_of_bounds' (1273563) panicked at arrow-buffer/src/buffer/immutable.rs:299:9:
the offset of the new Buffer cannot exceed the existing length: slice offset=4 length=8 selflen=8
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
reader::tests::test_read_record_batch_buffer_out_of_bounds
test result: FAILED. 141 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.54s
Expected behavior
should error and not panic
Additional context
Reported by Adam Korczynski from ADA Logics, identified by Anthropic
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 332
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/arrow-rs
-
[Variant] Parquet writer omits `specification_version` on the VARIANT logical typePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
parquet: panic (index out of bounds) reading FIXED_LEN_BYTE_ARRAY dictionary page with out-of-range indexPossibly taken @efegokdemir claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
`substring` errors when the bytes under a null `Utf8` slot would be cut inside a characterPossibly taken @cakeni claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/arrow-rs#11590 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
Similar issues
-
desktop documentation
Difficulty 1/5 Under an hour Newbie friendliness 90/100
vfarcic/dot-agent-deck#2008 ·
Maintainers usually reply within 1 day
-
needs triage
Difficulty 1/5 Under an hour Newbie friendliness 85/100
pbakaus/impeccable#1210 ·
Maintainers usually reply within 1 day
-
area: ci priority: P4 ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
shep-pm/shep#1249 · 1 comment ·
Maintainers usually reply within 1 day
-
L: javascript
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dependabot/dependabot-core#16744 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
nautechsystems/nautilus_trader#5486 · 1 comment ·
Maintainers usually reply within 1 day