Skip to content

Commit c54a93b

Browse files
committed
fuzz: Check invalid script flag combination
1 parent 1767f17 commit c54a93b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

fuzz/fuzz_targets/script_verify.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
use arbitrary::Arbitrary;
44
use libfuzzer_sys::fuzz_target;
55

6-
use bitcoinkernel::{verify, ScriptPubkey, Transaction, TxOut};
6+
use bitcoinkernel::{
7+
verify, KernelError, ScriptPubkey, ScriptVerifyError, Transaction, TxOut, VERIFY_WITNESS,
8+
};
79

810
#[derive(Debug, Arbitrary)]
911
pub struct UtxoWrapper {
@@ -39,12 +41,19 @@ fuzz_target!(|data: VerifyInput| {
3941
return;
4042
};
4143

42-
let _ = verify(
44+
let res = verify(
4345
&script_pubkey,
4446
data.amount,
4547
&transaction,
4648
data.input_index,
4749
data.flags,
4850
&spent_outputs,
4951
);
52+
53+
match res {
54+
Err(KernelError::ScriptVerify(ScriptVerifyError::InvalidFlagsCombination)) => {
55+
assert_eq!(data.flags.unwrap() & VERIFY_WITNESS, VERIFY_WITNESS)
56+
}
57+
_ => {}
58+
}
5059
});

0 commit comments

Comments
 (0)