/src/h2/fuzz/fuzz_targets/fuzz_client.rs
Line | Count | Source (jump to first uncovered line) |
1 | | #![no_main] |
2 | | use h2_support::prelude::*; |
3 | | use libfuzzer_sys::{arbitrary::Arbitrary, fuzz_target}; |
4 | | |
5 | 9.25k | #[derive(Debug, Arbitrary)] Unexecuted instantiation: <fuzz_client::HttpSpec as arbitrary::Arbitrary>::arbitrary::{closure#0} Unexecuted instantiation: <fuzz_client::HttpSpec as arbitrary::Arbitrary>::arbitrary::{closure#1} Unexecuted instantiation: <fuzz_client::HttpSpec as arbitrary::Arbitrary>::arbitrary::{closure#2} Unexecuted instantiation: <fuzz_client::HttpSpec as arbitrary::Arbitrary>::arbitrary_take_rest::{closure#0} <fuzz_client::HttpSpec as arbitrary::Arbitrary>::arbitrary_take_rest::{closure#1} Line | Count | Source | 5 | 4.62k | #[derive(Debug, Arbitrary)] |
Unexecuted instantiation: <fuzz_client::HttpSpec as arbitrary::Arbitrary>::arbitrary_take_rest::{closure#2} <fuzz_client::HttpSpec as arbitrary::Arbitrary>::try_size_hint::{closure#0} Line | Count | Source | 5 | 4.62k | #[derive(Debug, Arbitrary)] |
|
6 | | struct HttpSpec { |
7 | | uri: Vec<u8>, |
8 | | header_name: Vec<u8>, |
9 | | header_value: Vec<u8>, |
10 | | } |
11 | | |
12 | 4.62k | async fn fuzz_entry(inp: HttpSpec) { |
13 | 4.62k | if let Ok(req) = Request::builder() |
14 | 4.62k | .uri(&inp.uri[..]) |
15 | 4.62k | .header(&inp.header_name[..], &inp.header_value[..]) |
16 | 4.62k | .body(()) |
17 | | { |
18 | 448 | let (io, mut _srv) = mock::new(); |
19 | 448 | let (mut client, _h2) = client::Builder::new() |
20 | 448 | .handshake::<_, Bytes>(io) |
21 | 0 | .await |
22 | 448 | .unwrap(); |
23 | 448 | |
24 | 448 | // this could still trigger a user error: |
25 | 448 | // - if the uri isn't absolute |
26 | 448 | // - if the header name isn't allowed in http2 (like connection) |
27 | 448 | let _ = client.send_request(req, true); |
28 | 4.17k | } |
29 | 4.62k | } |
30 | | |
31 | | fuzz_target!(|inp: HttpSpec| { |
32 | | let rt = tokio::runtime::Runtime::new().unwrap(); |
33 | | rt.block_on(fuzz_entry(inp)); |
34 | | }); |