Skip to content

Commit 249369a

Browse files
author
Daniel Lockyer
committed
Updating fuzzing code to latest format
1 parent 6db4c40 commit 249369a

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

fuzz/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
target
3-
libfuzzer
3+
corpus
4+
artifacts

fuzz/Cargo.toml

Lines changed: 6 additions & 0 deletions
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

Lines changed: 6 additions & 12 deletions
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) {
13-
let url = url::Url::parse(utf8);
14-
}
15-
return 0;
16-
}
6+
fuzz_target!(|data: &[u8]| {
7+
if let Ok(utf8) = str::from_utf8(data) {
8+
let _ = url::Url::parse(utf8);
9+
}
10+
});

0 commit comments

Comments
 (0)