From 7206ef8ab85c921310ba45c1dd8b1621622aa696 Mon Sep 17 00:00:00 2001 From: jeffro256 Date: Mon, 8 May 2023 12:18:51 -0500 Subject: [PATCH] cryptonote_basic: fix amount overflow detection on 32-bit systems On systems where `ULONG_MAX` != `ULLONG_MAX` (e.g. most 32-bit systems), the `round_money_up` function will not correctly detect overflows. --- src/cryptonote_basic/cryptonote_format_utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index cdbcf48c2f3..9aeee3d5580 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -1229,7 +1229,7 @@ namespace cryptonote char *end = NULL; errno = 0; const unsigned long long ull = strtoull(buf, &end, 10); - CHECK_AND_ASSERT_THROW_MES(ull != ULONG_MAX || errno == 0, "Failed to parse rounded amount: " << buf); + CHECK_AND_ASSERT_THROW_MES(ull != ULLONG_MAX || errno == 0, "Failed to parse rounded amount: " << buf); CHECK_AND_ASSERT_THROW_MES(ull != 0 || amount == 0, "Overflow in rounding"); return ull; }