Skip to content

Commit

Permalink
Merge pull request #11 from adetaylor/fuzz
Browse files Browse the repository at this point in the history
Adding fuzzers for unsafe code.
  • Loading branch information
fenhl committed Jun 24, 2022
2 parents ca8e63a + 6480b2c commit 6064b48
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
31 changes: 31 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions fuzz/fuzz_targets/fuzz_next.rs
Original file line number Diff line number Diff line change
@@ -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() {}
}
});
9 changes: 9 additions & 0 deletions fuzz/fuzz_targets/fuzz_quote.rs
Original file line number Diff line number Diff line change
@@ -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);
}
});

0 comments on commit 6064b48

Please sign in to comment.