Skip to content

Commit 7e7058e

Browse files
committed
Integrate initial OSS-Fuzz support (#5850)
1 parent cff27db commit 7e7058e

File tree

3 files changed

+317
-0
lines changed

3 files changed

+317
-0
lines changed

Diff for: fuzz/Cargo.lock

+278
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: fuzz/Cargo.toml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[package]
2+
name = "fuzz"
3+
version = "0.0.0"
4+
edition = "2021"
5+
publish = false
6+
7+
[package.metadata]
8+
cargo-fuzz = true
9+
10+
[dependencies]
11+
libfuzzer-sys = "0.4.8"
12+
clap = { path = "../", version = "4.5.20", features = ["derive"] }
13+
14+
# Prevent this from interfering with workspaces
15+
[workspace]
16+
17+
[[bin]]
18+
name = "parse_fuzzer"
19+
path = "fuzz_targets/parse_fuzzer.rs"
20+
test = false
21+
doc = false
22+

Diff for: fuzz/fuzz_targets/parse_fuzzer.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![no_main]
2+
3+
use libfuzzer_sys::fuzz_target;
4+
use clap::Parser;
5+
6+
#[derive(Parser)]
7+
struct Args {
8+
#[arg(short, long)]
9+
test: String
10+
}
11+
12+
fuzz_target!(|data: &[u8]| {
13+
if let Ok(s) = String::from_utf8(data.to_vec()) {
14+
let _ = Args::try_parse_from(vec![s]);
15+
}
16+
});
17+

0 commit comments

Comments
 (0)