mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 11:15:56 +00:00
Fix Json Int/UInt comparison limit check
This commit is contained in:
committed by
Scott Schurr
parent
2e5ab4e0e3
commit
7e9ac16c22
@@ -402,10 +402,6 @@ int integerCmp (Int i, UInt ui)
|
||||
if (i < 0)
|
||||
return -1;
|
||||
|
||||
// All unsigned numbers with bit 0 set are too big for signed integers.
|
||||
if (ui & 0x8000)
|
||||
return 1;
|
||||
|
||||
// Now we can safely compare.
|
||||
return (i < ui) ? -1 : (i == ui) ? 0 : 1;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,13 @@ struct json_value_test : beast::unit_test::suite
|
||||
BEAST_EXPECT(j1["max_int"].asInt() == max_int);
|
||||
BEAST_EXPECT(j1["min_int"].asInt() == min_int);
|
||||
BEAST_EXPECT(j1["a_uint"].asUInt() == a_uint);
|
||||
BEAST_EXPECT(j1["a_uint"] > a_large_int);
|
||||
BEAST_EXPECT(j1["a_uint"] > a_small_int);
|
||||
BEAST_EXPECT(j1["a_large_int"].asInt() == a_large_int);
|
||||
BEAST_EXPECT(j1["a_large_int"].asUInt() == a_large_int);
|
||||
BEAST_EXPECT(j1["a_large_int"] < a_uint);
|
||||
BEAST_EXPECT(j1["a_small_int"].asInt() == a_small_int);
|
||||
BEAST_EXPECT(j1["a_small_int"] < a_uint);
|
||||
|
||||
json = "{\"overflow\":";
|
||||
json += std::to_string(std::uint64_t(max_uint) + 1);
|
||||
|
||||
Reference in New Issue
Block a user