Browse Source

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 -->
bors-servo 9 years ago
parent
commit
8b8d143ba0
3 changed files with 12 additions and 11 deletions
  1. 2 1
      fuzz/.gitignore
  2. 6 0
      fuzz/Cargo.toml
  3. 4 10
      fuzz/fuzzers/parse.rs

+ 2 - 1
fuzz/.gitignore

@@ -1,3 +1,4 @@
 
 target
-libfuzzer
+corpus
+artifacts

+ 6 - 0
fuzz/Cargo.toml

@@ -3,9 +3,15 @@
 name = "url-fuzz"
 version = "0.0.1"
 authors = ["Automatically generated"]
+publish = false
+
+[package.metadata]
+cargo-fuzz = true
 
 [dependencies.url]
 path = ".."
+[dependencies.libfuzzer-sys]
+git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
 
 [[bin]]
 name = "parse"

+ 4 - 10
fuzz/fuzzers/parse.rs

@@ -1,16 +1,10 @@
 #![no_main]
-
-extern crate libfuzzer_sys;
-
+#[macro_use] extern crate libfuzzer_sys;
 extern crate url;
-use std::slice;
 use std::str;
 
-#[export_name="LLVMFuzzerTestOneInput"]
-pub extern fn go(data: *const u8, size: isize) -> i32 {
-	let slice = unsafe { slice::from_raw_parts(data, size as usize) };
-	if let Ok(utf8) = str::from_utf8(slice) {
+fuzz_target!(|data: &[u8]| {
+	if let Ok(utf8) = str::from_utf8(data) {
 		let url = url::Url::parse(utf8);
 	}
-	return 0;
-}
+});