-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change API to be the same as Honggfuzz-rs and eventually AFL.rs
closes rust-fuzz/cargo-fuzz#119 closes rust-fuzz/cargo-fuzz#101
- Loading branch information
1 parent
86bcaac
commit 21b912f
Showing
2 changed files
with
93 additions
and
47 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,10 +1,23 @@ | ||
#![no_main] | ||
|
||
#[macro_use] | ||
extern crate libfuzzer_sys; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
if data == b"banana!" { | ||
panic!("success!"); | ||
} | ||
}); | ||
fn main() { | ||
// Here you can parse `std::env::args and | ||
// setup / initialize your project | ||
|
||
// The fuzz macro gives an arbitrary object (see `arbitrary crate`) | ||
// to a closure-like block of code. | ||
// For performance, it is recommended that you use the native type | ||
// `&[u8]` when possible. | ||
// Here, this slice will contain a "random" quantity of "random" data. | ||
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") | ||
}); | ||
} |
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