Something went wrong. Try again.
STreaming ARchive format: simpler, stricter, smaller than CARs for a subset of use-cases.
star car archive atproto
Something went wrong. Try again.
1.0 kB · 31 lines
Rust
at main
1234567891011121314151617181920212223242526272829303132//! Any byte string must either fail to parse or read to completion. Never a//! panic, never an unbounded loop.#![no_main]
use libfuzzer_sys::fuzz_target;use star_lite::Reader;use std::io::Cursor;
fuzz_target!(|data: &[u8]| { let Ok(mut reader) = Reader::new(Cursor::new(data)) else { return; };
// Every entry costs at least 3 bytes on the wire (two varints and one key // byte), so a well-behaved reader cannot yield more items than the input // has bytes. Bounding here turns a hang into an immediate failure instead // of relying on libFuzzer's timeout. let bound = data.len() + 2; let mut seen = 0usize; while let Some(item) = reader.next() { seen += 1; assert!(seen <= bound, "reader yielded more items than input bytes"); if item.is_err() { assert!( reader.next().is_none(), "an error must be terminal for the iterator" ); break; } }});