-
Notifications
You must be signed in to change notification settings - Fork 46
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 d055704
Showing
4 changed files
with
109 additions
and
53 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
#![no_main] | ||
|
||
#[macro_use] | ||
extern crate libfuzzer_sys; | ||
extern crate arbitrary; | ||
|
||
fn main() { | ||
// Here you can parse `std::env::args and | ||
// setup / initialize your project | ||
|
||
fuzz_target!(|data: u16| { | ||
if data == 0xba7 { // ba[nana] | ||
// 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: u16| { | ||
if data == 0xba7 { // ba[nana] | ||
panic!("success!"); | ||
} | ||
}); | ||
} | ||
}); | ||
} |
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