Skip to content

Commit

Permalink
fuzz: add target for Descriptor::parse_descriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoerg committed Dec 23, 2024
1 parent f3704d1 commit eb1e9f6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 23 additions & 0 deletions fuzz/fuzz_targets/parse_descriptor_priv.rs
Original file line number Diff line number Diff line change
@@ -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);
});
}
}

0 comments on commit eb1e9f6

Please sign in to comment.