Skip to content

Commit

Permalink
Add fuzzer (#5)
Browse files Browse the repository at this point in the history
After `cargo install cargo-fuzz`, you can run this with

    cargo fuzz run header-from-vec
  • Loading branch information
killercup authored and yoshuawuyts committed Jun 5, 2018
1 parent f52acc8 commit 9ce502e
Show file tree
Hide file tree
Showing 3 changed files with 35 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 = "sleep-parser-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false

[package.metadata]
cargo-fuzz = true

[dependencies.sleep-parser]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "header-from-vec"
path = "fuzz_targets/header-from-vec.rs"
9 changes: 9 additions & 0 deletions fuzz/fuzz_targets/header-from-vec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate sleep_parser;

fuzz_target!(|data: &[u8]| {
if let Ok(header) = sleep_parser::Header::from_vec(data) {
sleep_parser::Header::from_vec(&header.to_vec()).unwrap();
}
});

0 comments on commit 9ce502e

Please sign in to comment.