Add cargo-fuzz targets

memfd
Manos Pitsidianakis 4 years ago
parent b00d3c28c5
commit 0a34b082f6
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710

@ -123,3 +123,11 @@ cargo test -p {melib, meli} (-- --nocapture) (--test test_name)
perf record -g target/debug/bin
perf script | stackcollapse-perf | rust-unmangle | flamegraph > perf.svg
```
# Running fuzz targets
Note: `cargo-fuzz` requires the nightly toolchain.
```sh
cargo +nightly fuzz run envelope_parse -- -dict=fuzz/envelope_tokens.dict
```

4
fuzz/.gitignore vendored

@ -0,0 +1,4 @@
target
corpus
artifacts

2409
fuzz/Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -0,0 +1,24 @@
[package]
name = "melib-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.3"
[dependencies.melib]
path = "../melib"
features = ["unicode_algorithms"]
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "envelope_parse"
path = "fuzz_targets/envelope_parse.rs"

@ -0,0 +1,25 @@
","
";"
"<"
">"
"@"
":"
# tab character
"\x09"
# new line character
"\x0A"
" "
"Subject: "
"Subject"
"To"
"To: "
"Date"
"Date: "
"Message-Id"
"Message-Id: "
"From"
"From: "
"Cc"
"Cc: "
"Bcc"
"Bcc: "

@ -0,0 +1,11 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
extern crate melib;
use melib::Envelope;
fuzz_target!(|data: &[u8]| {
// fuzzed code goes here
let _envelope = Envelope::from_bytes(data, None);
});
Loading…
Cancel
Save