From eb1e9f63387045fe8e8d9bac2dad9708eba948be Mon Sep 17 00:00:00 2001 From: Bruno Garcia Date: Mon, 23 Dec 2024 15:07:26 -0300 Subject: [PATCH] fuzz: add target for `Descriptor::parse_descriptor` --- fuzz/Cargo.toml | 4 ++++ fuzz/fuzz_targets/parse_descriptor_priv.rs | 23 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 fuzz/fuzz_targets/parse_descriptor_priv.rs diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index d6f11f8e0..5ef91d949 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -30,6 +30,10 @@ path = "fuzz_targets/compile_taproot.rs" name = "parse_descriptor" path = "fuzz_targets/parse_descriptor.rs" +[[bin]] +name = "parse_descriptor_priv" +path = "fuzz_targets/parse_descriptor_priv.rs" + [[bin]] name = "parse_descriptor_secret" path = "fuzz_targets/parse_descriptor_secret.rs" diff --git a/fuzz/fuzz_targets/parse_descriptor_priv.rs b/fuzz/fuzz_targets/parse_descriptor_priv.rs new file mode 100644 index 000000000..98bfb992c --- /dev/null +++ b/fuzz/fuzz_targets/parse_descriptor_priv.rs @@ -0,0 +1,23 @@ +#![allow(unexpected_cfgs)] + +use honggfuzz::fuzz; +use miniscript::bitcoin::secp256k1; +use miniscript::Descriptor; + +fn do_test(data: &[u8]) { + let data_str = String::from_utf8_lossy(data); + let secp = &secp256k1::Secp256k1::signing_only(); + + if let Ok((desc, _)) = Descriptor::parse_descriptor(secp, &data_str) { + let _output = desc.to_string(); + let _sanity_check = desc.sanity_check(); + } +} + +fn main() { + loop { + fuzz!(|data| { + do_test(data); + }); + } +}