-
-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1209 from silvergasp/fuzz-gix-url
Fuzz more of gix_url::Url
- Loading branch information
Showing
2 changed files
with
25 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
#![no_main] | ||
use anyhow::Result; | ||
use libfuzzer_sys::fuzz_target; | ||
use std::hint::black_box; | ||
use std::path::Path; | ||
|
||
fn fuzz(data: &[u8]) -> Result<()> { | ||
let url = gix_url::parse(data.into())?; | ||
_ = black_box(url.user()); | ||
_ = black_box(url.password()); | ||
_ = black_box(url.password()); | ||
if let Some(safe_host) = black_box(url.host_argument_safe()) { | ||
// Ensure malicious host paths can't be returned see; | ||
// https://secure.phabricator.com/T12961 | ||
assert!(!safe_host.starts_with("ssh://-")); | ||
} | ||
_ = black_box(url.path_argument_safe()); | ||
_ = black_box(url.path_is_root()); | ||
_ = black_box(url.port_or_default()); | ||
_ = black_box(url.canonicalized(Path::new("/cwd"))); | ||
_ = black_box(url.to_bstring()); | ||
|
||
_ = black_box(gix_url::expand_path::parse(data.into())); | ||
Ok(()) | ||
} | ||
|
||
fuzz_target!(|data: &[u8]| { | ||
let _a = gix_url::parse(data.into()); | ||
_ = black_box(fuzz(data)); | ||
}); |