Skip to content

Commit

Permalink
Add fuzzing (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
jneem authored Oct 19, 2024
1 parent 3cade85 commit 42c8407
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"bench",
"bench/tools/gen_large_yaml",
"bench/tools/bench_compare",
"fuzz",
]
resolver = "2"

Expand Down
19 changes: 19 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "saphyr-fuzz"
version = "0.0.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"
saphyr.workspace = true

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

use libfuzzer_sys::fuzz_target;

fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let _ = saphyr::Yaml::load_from_str(s);
}
});

0 comments on commit 42c8407

Please sign in to comment.