From e8afcf56c124b228e4328760af6a7741b1bdd658 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sun, 19 Nov 2017 20:03:16 +0100 Subject: Add simple fuzzer for parser --- fuzz/.gitignore | 4 ++++ fuzz/Cargo.toml | 22 ++++++++++++++++++++++ fuzz/fuzz_targets/parse.rs | 9 +++++++++ 3 files changed, 35 insertions(+) create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/parse.rs 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..8aa3986 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,22 @@ + +[package] +name = "kairos-fuzz" +version = "0.0.1" +authors = ["Automatically generated"] +publish = false + +[package.metadata] +cargo-fuzz = true + +[dependencies.kairos] +path = ".." +[dependencies.libfuzzer-sys] +git = "https://github.com/rust-fuzz/libfuzzer-sys.git" + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "parse" +path = "fuzz_targets/parse.rs" diff --git a/fuzz/fuzz_targets/parse.rs b/fuzz/fuzz_targets/parse.rs new file mode 100644 index 0000000..5d6aa8b --- /dev/null +++ b/fuzz/fuzz_targets/parse.rs @@ -0,0 +1,9 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; +extern crate kairos; + +fuzz_target!(|data: &[u8]| { + if let Ok(data) = std::str::from_utf8(data) { + let _ = kairos::parser::parse(data); + } +}); -- cgit v1.2.3