Skip to content

Commit a9435e3

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22065: Mark CheckTxInputs [[nodiscard]]. Avoid UUM in fuzzing harness coins_view.
3737126 Mark `CheckTxInputs` `[[nodiscard]]` (out-param `txfee` only set if call is successful). Avoid UUM in fuzzing harness `coins_view`. (practicalswift) Pull request description: Mark `CheckTxInputs` `[[nodiscard]]` (out-param `txfee` only set if call is successful). Avoid use of uninitialised memory (UUM) in fuzzing harness `coins_view`. ACKs for top commit: MarcoFalke: review ACK 3737126 Tree-SHA512: edada5b2e80ce9ad3bd57b4c445bedefffa0a2d1cc880957d6848e4b7d9fc1ce036cd17f8b18bc03a36fbf84fc29c166cd6ac3dfbfe03e69d6fdbda13697754d
2 parents 0011167 + 3737126 commit a9435e3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/consensus/tx_verify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace Consensus {
2424
* @param[out] txfee Set to the transaction fee if successful.
2525
* Preconditions: tx.IsCoinBase() is false.
2626
*/
27-
bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
27+
[[nodiscard]] bool CheckTxInputs(const CTransaction& tx, TxValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee);
2828
} // namespace Consensus
2929

3030
/** Auxiliary functions for transaction validation (ideally should not be exposed) */

src/test/fuzz/coins_view.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,9 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
236236
// It is not allowed to call CheckTxInputs if CheckTransaction failed
237237
return;
238238
}
239-
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
240-
assert(MoneyRange(tx_fee_out));
239+
if (Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out)) {
240+
assert(MoneyRange(tx_fee_out));
241+
}
241242
},
242243
[&] {
243244
const CTransaction transaction{random_mutable_transaction};

0 commit comments

Comments
 (0)