Skip to content

Commit 8053710

Browse files
feat: Fuzz more of the gix-config api
1 parent c8c25c1 commit 8053710

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

gix-config/fuzz/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ edition = "2021"
1010
cargo-fuzz = true
1111

1212
[dependencies]
13-
libfuzzer-sys = "0.3"
13+
libfuzzer-sys = "0.4.7"
14+
arbitrary = { version = "1", features = ["derive"] }
1415

1516
[dependencies.gix-config]
1617
path = ".."

gix-config/fuzz/fuzz_targets/parse.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
#![no_main]
22

3+
use arbitrary::Arbitrary;
4+
use gix_config::{parse::Events, File};
35
use libfuzzer_sys::fuzz_target;
6+
use std::hint::black_box;
47

5-
fuzz_target!(|data: &[u8]| {
6-
// Don't name this _; Rust may optimize it out.
7-
let _a = gix_config::parse::from_bytes(data, &mut |_e| ());
8+
#[derive(Debug, Arbitrary, Clone)]
9+
struct Ctx<'a> {
10+
parse_from_bytes: &'a [u8],
11+
parse_file: &'a str,
12+
parse_events: &'a str,
13+
}
14+
15+
fuzz_target!(|ctx: Ctx| {
16+
_ = black_box(gix_config::parse::from_bytes(ctx.parse_from_bytes, &mut |_e| ()));
17+
_ = black_box(File::try_from(ctx.parse_file));
18+
_ = black_box(Events::try_from(ctx.parse_events));
819
});

0 commit comments

Comments
 (0)