Răsfoiți Sursa

Auto merge of #281 - Manishearth:fuzz, r=SimonSapin

Add fuzz scripts

Add a simple script for fuzzing with https://github.com/rust-fuzz/cargo-fuzz

Mostly autogenerated by cargo-fuzz; the contents of `go()` in parser.rs were
manually written.

cargo-fuzz is still WIP so the format here may change.

This can be fuzzed (on Linux only) with `cargo fuzz --target parser`

r? @SimonSapin

<!-- 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/281)
<!-- Reviewable:end -->
bors-servo 9 ani în urmă
părinte
comite
a03542ee32
3 a modificat fișierele cu 34 adăugiri și 0 ștergeri
  1. 3 0
      fuzz/.gitignore
  2. 15 0
      fuzz/Cargo.toml
  3. 16 0
      fuzz/fuzzers/parse.rs

+ 3 - 0
fuzz/.gitignore

@@ -0,0 +1,3 @@
+
+target
+libfuzzer

+ 15 - 0
fuzz/Cargo.toml

@@ -0,0 +1,15 @@
+
+[package]
+name = "url-fuzz"
+version = "0.0.1"
+authors = ["Automatically generated"]
+
+[dependencies.url]
+path = ".."
+
+[[bin]]
+name = "parse"
+path = "fuzzers/parse.rs"
+
+[workspace]
+members = ["."]

+ 16 - 0
fuzz/fuzzers/parse.rs

@@ -0,0 +1,16 @@
+#![no_main]
+
+extern crate fuzzer_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) {
+		let url = url::Url::parse(utf8);
+	}
+	return 0;
+}