Macro afl::fuzz

source ·
macro_rules! fuzz {
    ( $($x:tt)* ) => { ... };
}
Expand description

Fuzz a closure-like block of code by passing it an object of arbitrary type.

You can choose the type of the argument using the syntax as in the example below. Please check out the arbitrary crate to see which types are available.

For performance reasons, it is recommended that you use the native type &[u8] when possible.

fuzz!(|data: &[u8]| {
    if data.len() != 6 {return}
    if data[0] != b'q' {return}
    if data[1] != b'w' {return}
    if data[2] != b'e' {return}
    if data[3] != b'r' {return}
    if data[4] != b't' {return}
    if data[5] != b'y' {return}
    panic!("BOOM")
});