From f07c5447afb44a22395e5fdc09cb0ed2b5546fce Mon Sep 17 00:00:00 2001 From: davkor Date: Thu, 1 Apr 2021 15:43:32 +0100 Subject: [PATCH] initial fuzzer for oss-fuzz integration. --- fuzz/.gitignore | 4 ++++ fuzz/Cargo.toml | 26 ++++++++++++++++++++++++++ fuzz/fuzz_targets/fuzz_target_1.rs | 11 +++++++++++ 3 files changed, 41 insertions(+) create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/fuzz_target_1.rs diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..572e03b --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,4 @@ + +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..7d20ebd --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,26 @@ + +[package] +name = "unicode-segmentation-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2018" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" + +[dependencies.unicode-segmentation] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "fuzz_target_1" +path = "fuzz_targets/fuzz_target_1.rs" +test = false +doc = false diff --git a/fuzz/fuzz_targets/fuzz_target_1.rs b/fuzz/fuzz_targets/fuzz_target_1.rs new file mode 100644 index 0000000..9b863ff --- /dev/null +++ b/fuzz/fuzz_targets/fuzz_target_1.rs @@ -0,0 +1,11 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use unicode_segmentation::UnicodeSegmentation; + +fuzz_target!(|data: &[u8]| { + if let Ok(s) = std::str::from_utf8(data) { + let _g = s.graphemes(true).collect::>(); + let _w = s.unicode_words().collect::>(); + let _ws = s.split_word_bounds().collect::>(); + } +});