Lakshmi Narayanan Sreethar
279253ffd0
utils/big_decimal: fix scale overflow when parsing values with large exponents
...
The exponent of a big decimal string is parsed as an int32, adjusted for
the removed fractional part, and stored as an int32. When parsing values
like `1.23E-2147483647`, the unscaled value becomes `123`, and the scale
is adjusted to `2147483647 + 2 = 2147483649`. This exceeds the int32
limit, and since the scale is stored as an int32, it overflows and wraps
around, losing the value.
This patch fixes that the by parsing the exponent as an int64 value and
then adjusting it for the fractional part. The adjusted scale is then
checked to see if it is still within int32 limits before storing. An
exception is thrown if it is not within the int32 limits.
Note that strings with exponents that exceed the int32 range, like
`0.01E2147483650`, were previously not parseable as a big decimal. They
are now accepted if the final adjusted scale fits within int32 limits.
For the above value, unscaled_value = 1 and scale = -2147483648, so it
is now accepted. This is in line with how Java's `BigDecimal` parses
strings.
Fixes : #24581
Signed-off-by: Lakshmi Narayanan Sreethar <lakshmi.sreethar@scylladb.com >
Closes scylladb/scylladb#24640
2025-06-26 15:29:28 +03:00
..
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-04-28 12:30:13 +02:00
2025-05-30 12:21:51 +03:00
2025-06-18 20:36:45 +03:00
2024-12-23 23:37:02 +01:00
2025-03-17 10:03:06 +02:00
2025-02-19 12:12:28 +03:00
2024-12-23 23:37:02 +01:00
2024-12-23 23:37:02 +01:00
2025-05-29 13:05:08 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-06-26 15:29:28 +03:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-02-26 23:17:27 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-08-05 08:23:35 +03:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-03-06 10:22:05 +02:00
2025-05-14 16:19:40 +03:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-06-10 11:20:21 +03:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-08-05 08:23:35 +03:00
2025-02-25 10:32:32 +03:00
2025-02-25 10:32:32 +03:00
2025-02-06 11:33:59 +03:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-10-21 11:21:52 +03:00
2025-04-01 00:07:28 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-02-26 23:15:16 +02:00
2025-01-14 07:56:39 -05:00
2025-06-04 16:25:24 +03:00
2025-06-04 16:25:24 +03:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-02-26 23:17:27 +02:00
2025-01-07 13:22:00 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-04-29 15:47:33 -03:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-06-26 12:25:38 +02:00
2025-03-26 11:15:13 +01:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-04-12 11:47:02 +03:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-09 11:14:49 +02:00
2024-12-18 17:45:13 +02:00
2025-04-01 00:07:28 +02:00
2025-04-01 00:07:28 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-06-17 10:23:52 +03:00
2025-06-10 11:20:21 +03:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-03-20 14:54:09 +00:00
2025-03-20 14:54:09 +00:00
2025-03-03 16:58:38 +02:00
2025-03-03 16:58:38 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-03-06 10:22:05 +02:00
2025-01-14 07:56:39 -05:00
2025-04-30 16:43:22 +03:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-05-29 22:11:41 +03:00
2025-05-29 22:11:41 +03:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-04-16 22:06:06 +02:00
2024-12-18 17:45:13 +02:00
2025-04-28 12:30:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-03-06 12:17:32 +01:00
2024-12-18 17:45:13 +02:00
2025-04-12 11:47:00 +03:00
2025-04-12 11:47:00 +03:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-23 23:37:02 +01:00
2024-12-23 23:37:02 +01:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-02-17 08:01:38 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-12 14:50:29 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-04-01 00:07:28 +02:00
2024-12-18 17:45:13 +02:00
2024-12-24 12:19:20 +02:00
2025-02-26 23:23:53 +02:00
2025-01-26 15:54:06 +02:00
2025-05-27 12:43:11 +03:00
2025-05-27 12:43:11 +03:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-08-05 08:23:35 +03:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-21 16:24:45 +08:00
2024-12-18 17:45:13 +02:00
2025-06-23 17:54:01 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-02-25 10:32:32 +03:00
2025-01-14 07:56:39 -05:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2024-12-18 17:45:13 +02:00
2025-01-14 07:56:39 -05:00