diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..572e03b --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ + +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..4c8d927 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,22 @@ + +[package] +name = "flif-fuzz" +version = "0.0.1" +authors = ["Automatically generated"] +publish = false + +[package.metadata] +cargo-fuzz = true + +[dependencies.flif] +path = "../flif/" +[dependencies.libfuzzer-sys] +git = "https://github.com/rust-fuzz/libfuzzer-sys.git" + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "fuzz_flif" +path = "fuzz_targets/fuzz_flif.rs" diff --git a/fuzz/fuzz_targets/fuzz_flif.rs b/fuzz/fuzz_targets/fuzz_flif.rs new file mode 100644 index 0000000..c6bc318 --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_flif.rs @@ -0,0 +1,16 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; +extern crate flif; + +use std::io::Cursor; + +fuzz_target!(|data: &[u8]| { + let limits = flif::Limits { + metadata_chunk: 32, + metadata_count: 8, + pixels: 1<<16, + maniac_nodes: 512, + }; + let _ = flif::Flif::decode_with_limits(Cursor::new(data), limits) + .map(|img| img.get_raw_pixels()); +});