Skip to content

Commit 8b8d143

Browse files
author
bors-servo
authored
Auto merge of #342 - servo:bugfix/fuzzing, r=Manishearth
Bring fuzzer up to date Went to go run some fuzzing today and hit some speed bumps. This brings it up to date and inline with the latest versions. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-url/342) <!-- Reviewable:end -->
2 parents 780410c + 1b97ceb commit 8b8d143

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

fuzz/.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
target
3-
libfuzzer
3+
corpus
4+
artifacts

fuzz/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@
33
name = "url-fuzz"
44
version = "0.0.1"
55
authors = ["Automatically generated"]
6+
publish = false
7+
8+
[package.metadata]
9+
cargo-fuzz = true
610

711
[dependencies.url]
812
path = ".."
13+
[dependencies.libfuzzer-sys]
14+
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
915

1016
[[bin]]
1117
name = "parse"

fuzz/fuzzers/parse.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
#![no_main]
2-
3-
extern crate libfuzzer_sys;
4-
2+
#[macro_use] extern crate libfuzzer_sys;
53
extern crate url;
6-
use std::slice;
74
use std::str;
85

9-
#[export_name="LLVMFuzzerTestOneInput"]
10-
pub extern fn go(data: *const u8, size: isize) -> i32 {
11-
let slice = unsafe { slice::from_raw_parts(data, size as usize) };
12-
if let Ok(utf8) = str::from_utf8(slice) {
6+
fuzz_target!(|data: &[u8]| {
7+
if let Ok(utf8) = str::from_utf8(data) {
138
let url = url::Url::parse(utf8);
149
}
15-
return 0;
16-
}
10+
});

0 commit comments

Comments
 (0)