Skip to content

Commit

Permalink
Adding fuzzers for unsafe code.
Browse files Browse the repository at this point in the history
  • Loading branch information
adetaylor committed Feb 2, 2022
1 parent ca8e63a commit 6480b2c
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 6480b2c

Please sign in to comment.