Skip to content

Commit

Permalink
Add fuzzers for parsers.
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioBenitez committed Jan 22, 2023
1 parent 4295db8 commit f3c540e
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
33 changes: 33 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "cookie-fuzz"
version = "0.0.0"
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.cookie]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[profile.release]
debug = 1

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

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

extern crate cookie;

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &str| {
let _ = cookie::Cookie::parse(data);
});
10 changes: 10 additions & 0 deletions fuzz/fuzz_targets/split.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#![no_main]

extern crate cookie;

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &str| {
// Use `count()` to exhaust the iterator.
let _ = cookie::Cookie::split_parse(data).count();
});

0 comments on commit f3c540e

Please sign in to comment.