Skip to content

Commit 3550fff

Browse files
MarcoFalkePastaPastaPasta
authored andcommitted
Merge 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
1 parent 3520ac2 commit 3550fff

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
@@ -235,8 +235,9 @@ FUZZ_TARGET_INIT(coins_view, initialize_coins_view)
235235
// It is not allowed to call CheckTxInputs if CheckTransaction failed
236236
return;
237237
}
238-
(void)Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out);
239-
assert(MoneyRange(tx_fee_out));
238+
if (Consensus::CheckTxInputs(transaction, state, coins_view_cache, fuzzed_data_provider.ConsumeIntegralInRange<int>(0, std::numeric_limits<int>::max()), tx_fee_out)) {
239+
assert(MoneyRange(tx_fee_out));
240+
}
240241
},
241242
[&] {
242243
const CTransaction transaction{random_mutable_transaction};

0 commit comments

Comments
 (0)