Skip to content

Commit 20e252b

Browse files
Chandra Prataprustyrussell
authored andcommitted
fuzz-tests: fix overflow of u32 in fuzz-close-tx
Changelog-None: The value WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX is equal to 2.1e15, which is much higher than the maximum capacity of a u32, which is 4.29e9. Hence, use a u64 to store this value instead.
1 parent 17cf63a commit 20e252b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/fuzz/fuzz-close_tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void run(const uint8_t *data, size_t size)
5454
if (!(amount_sat_add(&funding, to_us, to_them)))
5555
return;
5656
/* .. And < max_btc as we assert it's not nonsensical! */
57-
max = AMOUNT_SAT((u32)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX);
57+
max = AMOUNT_SAT((u64)WALLY_SATOSHI_PER_BTC * WALLY_BTC_MAX);
5858
if (amount_sat_greater(funding, max)) {
5959
funding = max;
6060
to_us = amount_sat_div(max, 2);

0 commit comments

Comments
 (0)