check amount against MAX_MONEY with unsigned comparison

Because explicit conversion of arbitrarily large unsigned values
to signed values of the same bit width is implementation defined
until c++20, better check against MAX_MONEY with unsigned comparison.
This commit is contained in:
Dmitry Petukhov 2019-01-04 00:33:49 +05:00
parent 43f6cdbd31
commit 36a40e853f
No known key found for this signature in database
GPG key ID: 2301D26BDC15160D

View file

@ -95,7 +95,7 @@ bool UnblindConfidentialPair(const CKey &key, const CConfidentialValue& confValu
}
// Value sidechannel must be a transaction-valid amount (should be belt-and-suspenders check)
if (!MoneyRange((CAmount)amount)) {
if (amount > (uint64_t)MAX_MONEY || !MoneyRange((CAmount)amount)) {
return false;
}