-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change fuzzing API to mimic upstream's HF_ITER style
The library code is now a lot simpler, does not use macros and gives users a lot more control. This solves cargo-fuzz's issue rust-fuzz/cargo-fuzz#101 This syntax is also very similar to the one in AFL.rs. Maybe we should converge to a compatible API? rust-fuzz/afl.rs#31
- Loading branch information
1 parent
e33b471
commit 59c1977
Showing
2 changed files
with
39 additions
and
62 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,29 @@ | ||
#![no_main] | ||
#[macro_use] extern crate honggfuzz; | ||
extern crate honggfuzz; | ||
use honggfuzz::fuzz; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
if data.len() != 10 {return} | ||
if data[0] != 'q' as u8 {return} | ||
if data[1] != 'w' as u8 {return} | ||
if data[2] != 'e' as u8 {return} | ||
if data[3] != 'r' as u8 {return} | ||
if data[4] != 't' as u8 {return} | ||
if data[5] != 'y' as u8 {return} | ||
if data[6] != 'u' as u8 {return} | ||
if data[7] != 'i' as u8 {return} | ||
if data[8] != 'o' as u8 {return} | ||
if data[9] != 'p' as u8 {return} | ||
panic!("BOOM") | ||
}); | ||
fn main() { | ||
// Here you can parse `std::env::args and | ||
// setup / initialize your project | ||
|
||
// You have full control over the loop but | ||
// you're supposed to call `fuzz` ad vitam aeternam | ||
loop { | ||
// the fuzz function takes a closure which takes | ||
// a reference to a slice of u8. | ||
// This slice contains a "random" quantity of "random" data. | ||
fuzz(|data|{ | ||
if data.len() != 10 {return} | ||
if data[0] != 'q' as u8 {return} | ||
if data[1] != 'w' as u8 {return} | ||
if data[2] != 'e' as u8 {return} | ||
if data[3] != 'r' as u8 {return} | ||
if data[4] != 't' as u8 {return} | ||
if data[5] != 'y' as u8 {return} | ||
if data[6] != 'u' as u8 {return} | ||
if data[7] != 'i' as u8 {return} | ||
if data[8] != 'o' as u8 {return} | ||
if data[9] != 'p' as u8 {return} | ||
panic!("BOOM") | ||
}); | ||
} | ||
} |
This file contains 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