diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..1533360 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,31 @@ +[package] +name = "shlex-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.shlex] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "fuzz_next" +path = "fuzz_targets/fuzz_next.rs" +test = false +doc = false + +[[bin]] +name = "fuzz_quote" +path = "fuzz_targets/fuzz_quote.rs" +test = false +doc = false diff --git a/fuzz/fuzz_targets/fuzz_next.rs b/fuzz/fuzz_targets/fuzz_next.rs new file mode 100644 index 0000000..64b7a2a --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_next.rs @@ -0,0 +1,10 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; +use shlex::Shlex; + +fuzz_target!(|data: &[u8]| { + if let Ok(s) = std::str::from_utf8(data) { + let mut sh = Shlex::new(s); + while let Some(word) = sh.next() {} + } +}); diff --git a/fuzz/fuzz_targets/fuzz_quote.rs b/fuzz/fuzz_targets/fuzz_quote.rs new file mode 100644 index 0000000..2178dde --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_quote.rs @@ -0,0 +1,9 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; +use shlex::quote; + +fuzz_target!(|data: &[u8]| { + if let Ok(s) = std::str::from_utf8(data) { + quote(s); + } +});