#![no_main] use libfuzzer_sys::fuzz_target; const MAX_WALK_DEPTH: usize = 16; /// Walk groups/datasets from `group`, exercising every dataset-reading code /// path reachable through the public API (contiguous/chunked/compact raw /// reads via `chunked_read.rs`/`data_read.rs`). Depth-limited independently /// of any parser-level recursion guard, since this is fuzz-harness /// bookkeeping, not something under test. fn walk_group(group: &clawhdf5::Group, depth: usize) { if depth > MAX_WALK_DEPTH { return; } if let Ok(names) = group.datasets() { for name in names { if let Ok(dataset) = group.dataset(&name) { let _ = dataset.shape(); let _ = dataset.max_dimensions(); let _ = dataset.dtype(); let _ = dataset.read_raw_ref(); let _ = dataset.read_f64(); let _ = dataset.read_f32(); let _ = dataset.read_i32(); let _ = dataset.read_i64(); let _ = dataset.read_u64(); let _ = dataset.read_string(); } } } if let Ok(names) = group.groups() { for name in names { if let Ok(subgroup) = group.group(&name) { walk_group(&subgroup, depth + 1); } } } } fuzz_target!(|data: &[u8]| { let Ok(file) = clawhdf5::File::from_bytes(data.to_vec()) else { return; }; walk_group(&file.root(), 0); });