mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-20 12:29:22 +00:00
Merge bitcoin/bitcoin#32240: feefrac test: avoid integer overflow (bugfix)
a2bc330da86b604069308f5237b77cfa77ed2b43 feefrac test: avoid integer overflow (bugfix) (Pieter Wuille) Pull request description: The `feefrac_mul_div` fuzz test fails after #30535 with the following (base64) input: `Nb6Fc/97AACAAAD/ewAAgAAAAIAAAACAAAAAoA==` (see https://cirrus-ci.com/task/5240029192126464?logs=ci#L3353). This is caused by an internal multiplication inside `CFeeRate` that *just* exceeds the limit of the `int64_t` type. Fix that by tightening the bounds slightly further. ACKs for top commit: sr-gi: utACK a2bc330da86b604069308f5237b77cfa77ed2b43 instagibbs: ACK a2bc330da86b604069308f5237b77cfa77ed2b43 glozow: ACK a2bc330da86b604069308f5237b77cfa77ed2b43, was able to reproduce + verify this fix Tree-SHA512: cfbcdc8becfd518f4349ddc00c9af3ed0a23bb9534af71cc21df167d7038e5967127e5d97c4b3e8aeff6bf071c4f630c32ffaf81d8ec227954d21fdcbe205333
This commit is contained in:
commit
874da961d0
@ -220,9 +220,9 @@ FUZZ_TARGET(feefrac_mul_div)
|
||||
assert(res == res_fee);
|
||||
|
||||
// Compare approximately with CFeeRate.
|
||||
if (mul64 <= std::numeric_limits<int64_t>::max() / 1000 &&
|
||||
mul64 >= std::numeric_limits<int64_t>::min() / 1000 &&
|
||||
quot_abs <= arith_uint256{std::numeric_limits<int64_t>::max() / 1000}) {
|
||||
if (mul64 < std::numeric_limits<int64_t>::max() / 1000 &&
|
||||
mul64 > std::numeric_limits<int64_t>::min() / 1000 &&
|
||||
quot_abs < arith_uint256{std::numeric_limits<int64_t>::max() / 1000}) {
|
||||
CFeeRate feerate(mul64, (uint32_t)div);
|
||||
CAmount feerate_fee{feerate.GetFee(mul32)};
|
||||
auto allowed_gap = static_cast<int64_t>(mul32 / 1000 + 3 + round_down);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user