@@ -112,6 +112,10 @@ void MockTime(FuzzedDataProvider& fuzzed_data_provider, const CChainState& chain
112
112
113
113
FUZZ_TARGET_INIT (tx_pool_standard, initialize_tx_pool)
114
114
{
115
+ // Pick an arbitrary upper bound to limit the runtime and avoid timeouts on
116
+ // inputs.
117
+ int limit_max_ops{300 };
118
+
115
119
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
116
120
const auto & node = g_setup->m_node ;
117
121
auto & chainstate = node.chainman ->ActiveChainstate ();
@@ -142,7 +146,7 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
142
146
return c.out .nValue ;
143
147
};
144
148
145
- while (fuzzed_data_provider.ConsumeBool ()) {
149
+ while (--limit_max_ops >= 0 && fuzzed_data_provider.ConsumeBool ()) {
146
150
{
147
151
// Total supply is the mempool fee + all outpoints
148
152
CAmount supply_now{WITH_LOCK (tx_pool.cs , return tx_pool.GetTotalFee ())};
@@ -285,6 +289,10 @@ FUZZ_TARGET_INIT(tx_pool_standard, initialize_tx_pool)
285
289
286
290
FUZZ_TARGET_INIT (tx_pool, initialize_tx_pool)
287
291
{
292
+ // Pick an arbitrary upper bound to limit the runtime and avoid timeouts on
293
+ // inputs.
294
+ int limit_max_ops{300 };
295
+
288
296
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
289
297
const auto & node = g_setup->m_node ;
290
298
auto & chainstate = node.chainman ->ActiveChainstate ();
@@ -305,7 +313,7 @@ FUZZ_TARGET_INIT(tx_pool, initialize_tx_pool)
305
313
CTxMemPool tx_pool_{/* estimator */ nullptr , /* check_ratio */ 1 };
306
314
MockedTxPool& tx_pool = *static_cast <MockedTxPool*>(&tx_pool_);
307
315
308
- while (fuzzed_data_provider.ConsumeBool ()) {
316
+ while (--limit_max_ops >= 0 && fuzzed_data_provider.ConsumeBool ()) {
309
317
const auto mut_tx = ConsumeTransaction (fuzzed_data_provider, txids);
310
318
311
319
if (fuzzed_data_provider.ConsumeBool ()) {
0 commit comments