Initial oss-fuzz integration. (#529)

Signed-off-by: davkor <david@adalogics.com>
This commit is contained in:
DavidKorczynski
2021-04-16 22:58:07 +01:00
committed by GitHub
parent 2c53d60098
commit 9c7f47af95
9 changed files with 374 additions and 133 deletions

View File

@@ -0,0 +1,31 @@
#![no_main]
use h2_support::prelude::*;
use libfuzzer_sys::{arbitrary::Arbitrary, fuzz_target};
#[derive(Debug, Arbitrary)]
struct HttpSpec {
uri: Vec<u8>,
header_name: Vec<u8>,
header_value: Vec<u8>,
}
async fn fuzz_entry(inp: HttpSpec) {
if let Ok(req) = Request::builder()
.uri(&inp.uri[..])
.header(&inp.header_name[..], &inp.header_value[..])
.body(())
{
let (io, mut _srv) = mock::new();
let (mut client, _h2) = client::Builder::new()
.handshake::<_, Bytes>(io)
.await
.unwrap();
let (_, _) = client.send_request(req, true).unwrap();
}
}
fuzz_target!(|inp: HttpSpec| {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(fuzz_entry(inp));
});