From 36a40e853ff67fd468367e0b052bcf510f01e386 Mon Sep 17 00:00:00 2001 From: Dmitry Petukhov Date: Fri, 4 Jan 2019 00:33:49 +0500 Subject: [PATCH] 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. --- src/blind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/blind.cpp b/src/blind.cpp index c40df087de..10fd464540 100644 --- a/src/blind.cpp +++ b/src/blind.cpp @@ -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; }