Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fuzz crate #660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions url/fuzz/Cargo.toml
@@ -1,9 +1,10 @@

[package]
name = "url-fuzz"
version = "0.0.1"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true
Expand All @@ -14,9 +15,12 @@ libfuzzer-sys = "0.4.0"
[dependencies.url]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "parse"
path = "fuzz_targets/parse.rs"

[workspace]
members = ["."]
test = false
doc = false
15 changes: 6 additions & 9 deletions url/fuzz/fuzz_targets/parse.rs
@@ -1,13 +1,10 @@
#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate url;
use std::str;
use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
if let Ok(utf8) = str::from_utf8(data) {
if let Ok(parsed) = url::Url::parse(utf8) {
let as_str = parsed.as_str();
assert_eq!(parsed, url::Url::parse(as_str).unwrap());
}
fuzz_target!(|data: String| {
if let Ok(parsed) = url::Url::parse(data.as_str()) {
let as_str = parsed.as_str();
let parsed_again = url::Url::parse(as_str).unwrap();
assert_eq!(parsed, parsed_again);
}
});