lac/fuzz/fuzz_targets/decode_arbitrary.rs
Kamal Tufekcic 7862cb1d9d
All checks were successful
CI / lint (push) Successful in 5s
CI / fuzz-regression (push) Successful in 14s
CI / build (push) Successful in 4s
CI / test (push) Successful in 6m54s
CI / publish (push) Successful in 8s
initial commit
Signed-off-by: Kamal Tufekcic <kamal@lo.sh>
2026-04-23 14:58:32 +03:00

26 lines
1.1 KiB
Rust

//! Fuzzer for `decode_frame` against arbitrary byte input.
//!
//! Drives the frame parser and Rice bitstream decoder with random bytes.
//! The decoder must never panic, allocate unboundedly, or enter an infinite
//! loop on any input: success is "returns `Ok` with valid samples" or
//! "returns `Err(DecodeError)`". Nothing else is acceptable.
//!
//! Paths exercised:
//! - Every header validation branch (sync, order range, partition order
//! range, truncation at each field boundary, partition count vs. sample
//! count mismatch).
//! - The Rice unary-decode loop with pathological run lengths (the
//! `q > 2^26` guard in `rice::rice_decode` is specifically targeted).
//! - The Q15 predictor accumulator on adversarial coefficient and residual
//! values (overflow / wrap-around checks).
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
// Only the `Ok` / `Err` result is meaningful; panics are the failure
// mode. The returned samples themselves are unchecked here — the
// `roundtrip_arbitrary` target verifies encoder/decoder self-consistency.
let _ = lac::decode_frame(data);
});