Skip to content

Commit c2a57be

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

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

fuzz/fuzz_targets/script_verify.rs

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

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

88
#[derive(Debug, Arbitrary)]
99
pub struct UtxoWrapper {
@@ -39,12 +39,19 @@ fuzz_target!(|data: VerifyInput| {
3939
return;
4040
};
4141

42-
let _ = verify(
42+
let res = verify(
4343
&script_pubkey,
4444
data.amount,
4545
&transaction,
4646
data.input_index,
4747
data.flags,
4848
&spent_outputs,
4949
);
50+
51+
match res {
52+
Err(KernelError::ScriptVerify(ScriptVerifyError::InvalidFlagsCombination)) => {
53+
assert_eq!(data.flags.unwrap() & VERIFY_WITNESS, VERIFY_WITNESS)
54+
}
55+
_ => {}
56+
}
5057
});

0 commit comments

Comments
 (0)