Skip to content

Commit 7d19c85

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#21970: fuzz: Add missing CheckTransaction before CheckTxInputs
fae4ee5 fuzz: Add missing CheckTransaction before CheckTxInputs (MarcoFalke) faacb7e fuzz: Sanity check result of CheckTransaction (MarcoFalke) Pull request description: This bug was introduced by myself in commit eeee8f5 (bitcoin/bitcoin#21553) Reproducer: https://github.com/bitcoin/bitcoin/files/6492249/clusterfuzz-testcase-minimized-coins_view-6109460079706112.log Hopefully fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=34301 ACKs for top commit: practicalswift: cr ACK fae4ee5: patch looks correct :) Tree-SHA512: 9ece7a5c4bfa60f5e5ffeba3f0ee52a07944c9bd6102588dd7ff7405695e6b32449945b7c41bd25baf38814df5a2436521e655ceff87223ad03c69ed39053023
2 parents ff438a1 + fae4ee5 commit 7d19c85

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/test/fuzz/coins_view.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <chainparams.h>
77
#include <chainparamsbase.h>
88
#include <coins.h>
9+
#include <consensus/tx_check.h>
910
#include <consensus/tx_verify.h>
1011
#include <consensus/validation.h>
1112
#include <key.h>
@@ -230,6 +231,11 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
230231
// consensus/tx_verify.cpp:171: bool Consensus::CheckTxInputs(const CTransaction &, TxValidationState &, const CCoinsViewCache &, int, CAmount &): Assertion `!coin.IsSpent()' failed.
231232
return;
232233
}
234+
TxValidationState dummy;
235+
if (!CheckTransaction(transaction, dummy)) {
236+
// It is not allowed to call CheckTxInputs if CheckTransaction failed
237+
return;
238+
}
233239
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
234240
assert(MoneyRange(tx_fee_out));
235241
},

src/test/fuzz/transaction.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
6161
return;
6262
}
6363

64-
TxValidationState state_with_dupe_check;
65-
(void)CheckTransaction(tx, state_with_dupe_check);
64+
{
65+
TxValidationState state_with_dupe_check;
66+
const bool res{CheckTransaction(tx, state_with_dupe_check)};
67+
Assert(res == state_with_dupe_check.IsValid());
68+
}
6669

6770
const CFeeRate dust_relay_fee{DUST_RELAY_TX_FEE};
6871
std::string reason;

0 commit comments

Comments
 (0)