Initial fuzzer set up. (#478)

This commit is contained in:
DavidKorczynski
2021-04-10 16:43:59 +01:00
committed by GitHub
parent 8698e76a0e
commit 04776e9522
2 changed files with 49 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
[package]
name = "http-fuzz"
version = "0.0.0"
authors = ["David Korczynski <david@adalogics.com>"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
arbitrary = { version = "1", features = ["derive"] }
libfuzzer-sys = { version = "0.4.0", features = ["arbitrary-derive"] }
[dependencies.http]
path = ".."
[[bin]]
name = "fuzz_http"
path = "src/fuzz_http.rs"
[workspace]
+27
View File
@@ -0,0 +1,27 @@
#![no_main]
use http::Request;
use http::Response;
use http::StatusCode;
use libfuzzer_sys::arbitrary::Arbitrary;
use libfuzzer_sys::fuzz_target;
#[derive(Debug, Arbitrary)]
struct HttpSpec {
uri: Vec<u8>,
header_name: Vec<u8>,
header_value: Vec<u8>,
status_codes: Vec<u8>,
}
fuzz_target!(|inp: HttpSpec| {
let _ = Request::builder()
.uri(&inp.uri[..])
.header(&inp.header_name[..], &inp.header_value[..])
.body(());
let _ = Response::builder()
.header(&inp.header_name[..], &inp.header_value[..])
.body(());
let _ = StatusCode::from_bytes(&inp.status_codes[..]);
});