Skip to content

Commit 19e1b7b

Browse files
Fuzz more of gix_url::Url
1 parent c1e4c62 commit 19e1b7b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

gix-url/fuzz/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition = "2021"
99
cargo-fuzz = true
1010

1111
[dependencies]
12+
anyhow = "1.0.76"
1213
libfuzzer-sys = "0.4"
1314

1415
[dependencies.gix-url]

gix-url/fuzz/fuzz_targets/parse.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
#![no_main]
2+
use anyhow::Result;
23
use libfuzzer_sys::fuzz_target;
4+
use std::hint::black_box;
5+
use std::path::Path;
6+
7+
fn fuzz(data: &[u8]) -> Result<()> {
8+
let url = gix_url::parse(data.into())?;
9+
_ = black_box(url.user());
10+
_ = black_box(url.password());
11+
_ = black_box(url.password());
12+
_ = black_box(url.host_argument_safe());
13+
_ = black_box(url.path_argument_safe());
14+
_ = black_box(url.path_is_root());
15+
_ = black_box(url.port_or_default());
16+
_ = black_box(url.canonicalized(Path::new("/cwd")));
17+
_ = black_box(url.to_bstring());
18+
19+
_ = black_box(gix_url::expand_path::parse(data.into()));
20+
Ok(())
21+
}
322

423
fuzz_target!(|data: &[u8]| {
5-
let _a = gix_url::parse(data.into());
24+
_ = black_box(fuzz(data));
625
});

0 commit comments

Comments
 (0)