mirror of
https://gitee.com/openharmony/third_party_rust_shlex
synced 2024-11-23 07:39:56 +00:00
Adding fuzzers for unsafe code.
This commit is contained in:
parent
ca8e63a6e9
commit
6480b2c2a0
31
fuzz/Cargo.toml
Normal file
31
fuzz/Cargo.toml
Normal file
@ -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
fuzz/fuzz_targets/fuzz_next.rs
Normal file
10
fuzz/fuzz_targets/fuzz_next.rs
Normal file
@ -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
fuzz/fuzz_targets/fuzz_quote.rs
Normal file
9
fuzz/fuzz_targets/fuzz_quote.rs
Normal file
@ -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);
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user