Skip to content

Commit 1ac627c

Browse files
committed
Merge bitcoin/bitcoin#29462: [fuzz] Avoid partial negative result
9dae3b9 [fuzz] Avoid partial negative result (Murch) Pull request description: May address the problem reported by maflcko in bitcoin/bitcoin#27877 (review). For some values, `MAX_MONEY - max_spendable - max_output_groups` could result in a partial negative value. By putting the addition of `group_pos.size()` first, all partial results in this line will be strictly positive. I opened this as a draft, since I was unable to reproduce the issue, so I’m waiting for confirmation whether this in fact mitigates the problem. ACKs for top commit: maflcko: ACK 9dae3b9 sipa: utACK 9dae3b9 achow101: ACK 9dae3b9 brunoerg: crACK 9dae3b9 Tree-SHA512: 744b4706268d8dfd77538b99492ecf3cf77d229095f9bcd416a412131336830e2f134f2b2846c79abd3d193426f97c1f71eeaf68b16ab00e76318d57ee3673c7
2 parents 88b1229 + 9dae3b9 commit 1ac627c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/wallet/test/fuzz/coinselection.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ FUZZ_TARGET(coin_grinder_is_optimal)
158158
// Only make UTXOs with positive effective value
159159
const CAmount input_fee = coin_params.m_effective_feerate.GetFee(n_input_bytes);
160160
// Ensure that each UTXO has at least an effective value of 1 sat
161-
const CAmount eff_value{fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(1, MAX_MONEY - max_spendable - max_output_groups + group_pos.size())};
161+
const CAmount eff_value{fuzzed_data_provider.ConsumeIntegralInRange<CAmount>(1, MAX_MONEY + group_pos.size() - max_spendable - max_output_groups)};
162162
const CAmount amount{eff_value + input_fee};
163163
std::vector<COutput> temp_utxo_pool;
164164

0 commit comments

Comments
 (0)