Created
August 28, 2023 05:15
-
-
Save jmcph4/f7c1b59cf0f1b4c084f9dc59fc699adf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[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