-
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
0c45075
commit 785aa9c
Showing
4 changed files
with
107 additions
and
80 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,9 +1,9 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
if data == b"banana!" { | ||
panic!("success!"); | ||
} | ||
}); | ||
fn main() { | ||
fuzz!(|data: &[u8]| { | ||
if data == b"banana!" { | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz; | ||
|
||
use libfuzzer_sys::fuzz_target; | ||
fn main() { | ||
// Here you can parse `std::env::args and | ||
// setup / initialize your project | ||
|
||
fuzz_target!(|data: u16| { | ||
if data == 0xba7 { // ba[nana] | ||
panic!("success!"); | ||
} | ||
}); | ||
// 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