Skip to content

Commit

Permalink
Add basic fuzzing harness (#35)
Browse files Browse the repository at this point in the history
* Add inital fuzz harness

* Fix fuzz target

* Change input type to one that impls arbitrary

* Add fuzz lockfile
  • Loading branch information
adumbidiot committed Oct 25, 2022
1 parent e84e223 commit 4eb08c5
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ exclude = [
"Makefile",
"deny.toml",
"bindings",
"fuzz/*",
"test_data/*",
]

[dependencies]
Expand Down
3 changes: 3 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
corpus
artifacts
62 changes: 62 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "lz-str-fuzz"
version = "0.0.0"
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.lz-str]
path = ".."

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

[[bin]]
name = "compress-decompress"
path = "fuzz_targets/compress_decompress.rs"
test = false
doc = false
8 changes: 8 additions & 0 deletions fuzz/fuzz_targets/compress_decompress.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![no_main]
use libfuzzer_sys::fuzz_target;

fuzz_target!(|input: Vec<u16>| {
let compressed = lz_str::compress(&input);
let decompressed = lz_str::decompress(&compressed).unwrap();
assert!(input == decompressed);
});

0 comments on commit 4eb08c5

Please sign in to comment.