Validate GDSII record sizes through one fallible path

Route every record read through size validation and report malformed payloads
as parse errors instead of panicking. Apply metadata size constraints through
the Record trait, hide Arrow reader internals, and remove unused wrappers and
scratch code.

Add coverage for direct, skipped, and payload reads, truncated buffers, and
FFI error offsets.
This commit is contained in:
Jan Petykiewicz 2026-11-16 20:44:48 -08:00
commit 54aa757678

View file

@ -31,20 +31,20 @@ fn error_message() -> String {
}
#[test]
fn path_errors_preserve_outputs_and_convert_parser_panics() {
fn path_errors_preserve_outputs_and_clear_after_success() {
let mut array = FFI_ArrowArray::empty();
let mut schema = FFI_ArrowSchema::empty();
assert_eq!(unsafe { read_path(ptr::null(), &mut array, &mut schema) }, -1);
assert!(error_message().contains("path pointer was null"));
assert!(array.is_released());
// A mismatched timestamp size currently makes Record::read panic.
// A mismatched timestamp size returns a parse error with a byte offset.
let mut bytes = Vec::new();
common::record(&mut bytes, records::RTAG_HEADER, &600_i16.to_be_bytes());
common::record(&mut bytes, records::RTAG_BGNLIB, &[0; 12]);
let file = TestFile::new("invalid-timestamps", &bytes);
assert_eq!(unsafe { read_path(file.cpath().as_ptr(), &mut array, &mut schema) }, -1);
assert!(error_message().contains("Expected record size"));
assert!(error_message().contains("read failed at byte 10: Expected record size"));
assert!(array.is_released());
let mut bytes = common::library_header();