Skip to content

Commit

Permalink
cargo-fuzz: add new targets with relaxed multiple space options
Browse files Browse the repository at this point in the history
Add two new targets to fuzz parsing requests and responses with
multiple spaces enabled via ParserConfig.
  • Loading branch information
00xc committed May 24, 2023
1 parent 7827885 commit a206fdd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,15 @@ name = "parse_response"
path = "fuzz_targets/parse_response.rs"
test = false
doc = false

[[bin]]
name = "parse_response_multspaces"
path = "fuzz_targets/parse_response_multspaces.rs"
test = false
doc = false

[[bin]]
name = "parse_request_multspaces"
path = "fuzz_targets/parse_request_multspaces.rs"
test = false
doc = false
11 changes: 11 additions & 0 deletions fuzz/fuzz_targets/parse_request_multspaces.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let mut headers = [httparse::EMPTY_HEADER; 16];
let mut resp = httparse::Request::new(&mut headers);
let _ = httparse::ParserConfig::default()
.allow_multiple_spaces_in_request_line_delimiters(true)
.parse_request(&mut resp, data);
});
11 changes: 11 additions & 0 deletions fuzz/fuzz_targets/parse_response_multspaces.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#![no_main]

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
let mut headers = [httparse::EMPTY_HEADER; 16];
let mut resp = httparse::Response::new(&mut headers);
let _ = httparse::ParserConfig::default()
.allow_multiple_spaces_in_response_status_delimiters(true)
.parse_response(&mut resp, data);
});

0 comments on commit a206fdd

Please sign in to comment.