diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 0000000..a092511 --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,3 @@ +target +corpus +artifacts diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 0000000..4b6dd60 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,26 @@ +[package] +name = "json5-fuzz" +version = "0.0.0" +authors = ["Automatically generated"] +publish = false +edition = "2021" + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" +serde_json = "1.0.74" + +[dependencies.json5] +path = ".." + +# Prevent this from interfering with workspaces +[workspace] +members = ["."] + +[[bin]] +name = "strings" +path = "fuzz_targets/strings.rs" +test = false +doc = false diff --git a/fuzz/fuzz_targets/strings.rs b/fuzz/fuzz_targets/strings.rs new file mode 100644 index 0000000..1282243 --- /dev/null +++ b/fuzz/fuzz_targets/strings.rs @@ -0,0 +1,9 @@ +#![no_main] + +use libfuzzer_sys::fuzz_target; + +fuzz_target!(|data: &str| { + if let Ok(value) = json5::from_str::(data) { + json5::to_string(&value).expect("serialization failed"); + } +});