Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Created August 28, 2023 05:15
Show Gist options
  • Select an option

  • Save jmcph4/f7c1b59cf0f1b4c084f9dc59fc699adf to your computer and use it in GitHub Desktop.

Select an option

Save jmcph4/f7c1b59cf0f1b4c084f9dc59fc699adf to your computer and use it in GitHub Desktop.
#[macro_use]
extern crate honggfuzz;
const MIN_LEN: usize = 8000;
const SPECIAL_LOC: usize = MIN_LEN - 200;
const SPECIAL_CHAR: u8 = b'A';
fn parse(s: &str) -> bool {
if s.len() >= MIN_LEN {
if s.as_bytes()[SPECIAL_LOC] == SPECIAL_CHAR {
panic!(); /* BANG! */
} else {
true
}
} else {
false
}
}
fn main() {
loop {
fuzz!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let _: bool = parse(s);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment