Skip to content

Commit

Permalink
Added fuzzy testing (#26)
Browse files Browse the repository at this point in the history
* added fuzzy testing

* revert formatting change

* removed artifact test

* revert metadata changes

* added fuzz limits
  • Loading branch information
newpavlov authored and ZoeyR committed Jun 9, 2018
1 parent 7c9811a commit 2838f09
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

target
corpus
artifacts
22 changes: 22 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 16 additions & 0 deletions fuzz/fuzz_targets/fuzz_flif.rs
Original file line number Diff line number Diff line change
@@ -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());
});

0 comments on commit 2838f09

Please sign in to comment.