Skip to content

Commit b3a921c

Browse files
Add honggfuzz as an alternative fuzzer
Closes GH-55. Reviewed-by: Titus Wormer <[email protected]>
1 parent 2498e31 commit b3a921c

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ unicode-data.txt
88
fuzz/target
99
fuzz/corpus
1010
fuzz/artifacts
11+
fuzz/hfuzz_target
12+
fuzz/hfuzz_workspace

fuzz/Cargo.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cargo-fuzz = true
1010

1111
[dependencies]
1212
libfuzzer-sys = "0.4"
13+
honggfuzz = "0.5"
1314

1415
[dependencies.markdown]
1516
path = ".."
@@ -19,7 +20,13 @@ path = ".."
1920
members = ["."]
2021

2122
[[bin]]
22-
name = "markdown"
23-
path = "fuzz_targets/markdown.rs"
23+
name = "markdown_libfuzz"
24+
path = "fuzz_targets/markdown_libfuzz.rs"
2425
test = false
2526
doc = false
27+
28+
[[bin]]
29+
name = "markdown_honggfuzz"
30+
path = "fuzz_targets/markdown_honggfuzz.rs"
31+
test = false
32+
doc = false
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use honggfuzz::fuzz;
2+
3+
fn main() {
4+
loop {
5+
fuzz!(|data: &[u8]| {
6+
if let Ok(s) = std::str::from_utf8(data) {
7+
let _ = markdown::to_html(s);
8+
let _ = markdown::to_html_with_options(s, &markdown::Options::gfm());
9+
let _ = markdown::to_mdast(s, &markdown::ParseOptions::default());
10+
let _ = markdown::to_mdast(s, &markdown::ParseOptions::gfm());
11+
let _ = markdown::to_mdast(s, &markdown::ParseOptions::mdx());
12+
}
13+
});
14+
}
15+
}
File renamed without changes.

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ The following bash scripts are useful when working on this project:
268268
* fuzz:
269269
```sh
270270
cargo install cargo-fuzz
271-
cargo +nightly fuzz run markdown
271+
cargo install honggfuzz
272+
cargo +nightly fuzz run markdown_libfuzz
273+
cargo hfuzz run markdown_honggfuzz
272274
```
273275

274276
### Version

0 commit comments

Comments
 (0)