Skip to content

Commit e0fc688

Browse files
authored
Merge pull request #131 from darosior/descriptor_publickey
DescriptorPublicKey, second pass
2 parents 7236b57 + 28158a3 commit e0fc688

File tree

3 files changed

+489
-1
lines changed

3 files changed

+489
-1
lines changed

fuzz/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,8 @@ path = "fuzz_targets/roundtrip_semantic.rs"
4343

4444
[[bin]]
4545
name = "compile_descriptor"
46-
path = "fuzz_targets/compile_descriptor.rs"
46+
path = "fuzz_targets/compile_descriptor.rs"
47+
48+
[[bin]]
49+
name = "parse_descriptor"
50+
path = "fuzz_targets/parse_descriptor.rs"

fuzz/fuzz_targets/parse_descriptor.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
extern crate miniscript;
2+
3+
use miniscript::descriptor::DescriptorPublicKey;
4+
use std::str::FromStr;
5+
6+
fn do_test(data: &[u8]) {
7+
let data_str = String::from_utf8_lossy(data);
8+
if let Ok(dpk) = DescriptorPublicKey::from_str(&data_str) {
9+
let output = dpk.to_string();
10+
assert_eq!(data_str.to_lowercase(), output.to_lowercase());
11+
}
12+
}
13+
14+
#[cfg(feature = "afl")]
15+
extern crate afl;
16+
#[cfg(feature = "afl")]
17+
fn main() {
18+
afl::read_stdio_bytes(|data| {
19+
do_test(&data);
20+
});
21+
}
22+
23+
#[cfg(feature = "honggfuzz")]
24+
#[macro_use]
25+
extern crate honggfuzz;
26+
#[cfg(feature = "honggfuzz")]
27+
fn main() {
28+
loop {
29+
fuzz!(|data| {
30+
do_test(data);
31+
});
32+
}
33+
}

0 commit comments

Comments
 (0)