Function hongg::fuzz

source ·
pub fn fuzz<F>(closure: F)where
    F: FnOnce(&[u8]),
Expand description

Fuzz a closure by passing it a &[u8]

This slice contains a “random” quantity of “random” data.

For perstistent fuzzing to work, you have to call it ad vita aeternam in an infinite loop.

The closure is assumed to be unwind-safe, which might be unsafe. For more info, check the std::panic::UnwindSafe trait.

loop {
    fuzz(|data|{
        if data.len() != 3 {return}
        if data[0] != b'h' {return}
        if data[1] != b'e' {return}
        if data[2] != b'y' {return}
        panic!("BOOM")
    });
}