Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

png-afl: document usage and minor tweaks #133

Merged
merged 1 commit into from
May 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions png-afl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
6 changes: 2 additions & 4 deletions png-afl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ version = "0.2.0"
authors = ["Sergey Davidoff <shnatsel@gmail.com>", "Paul Grandperrin <paul.grandperrin@gmail.com>"]

[dependencies]
afl = "0.4.0"
png = {path = "../"}


afl = "0.4.3"
png = { path = "../" }
17 changes: 17 additions & 0 deletions png-afl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Build fuzzer binary

RUSTFLAGS='-C codegen-units=1' cargo afl build

NOTE: the RUSTFLAGS is only needed on Linux (and not if using gold linker), see https://github.com/rust-lang/rust/issues/53945


## Run fuzzer

cargo afl fuzz -m 200 -i fuzzing_seeds -o out target/debug/png-afl

NOTE: -m 200 sets memory limit to 200 mb. afl defaults to 50 megabytes memory usage. If we would not increase it, many invocations will exit with SIGABRT and look like crashes.


### More info

https://rust-fuzz.github.io/book/afl/tutorial.html
6 changes: 3 additions & 3 deletions png-afl/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[macro_use]
extern crate afl;
extern crate png;

Expand Down Expand Up @@ -25,8 +26,7 @@ fn png_decode(data: &[u8]) -> Result<(png::OutputInfo, Vec<u8>), ()> {
}

fn main() {
afl::fuzz(|data| {
//afl::read_stdio_bytes(|data| {
png_decode(&data);
fuzz!(|data: &[u8]| {
let _ = png_decode(&data);
});
}