This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit f56c15ff89baf3dcad16c1e14df3ea2e4e9238c1
Author: Boris Faure <[email protected]>
AuthorDate: Mon Nov 9 10:30:45 2026 +0000
eina: stop growing a strtod_c exponent past a double's range
eina_convert_strtod_c() read the exponent into an unsigned int with no
bound. A longer one wrapped around: 1e4294967297 came back as 10, not
infinity, and 1e-4294967297 as 0.1. Short of wrapping, the scaling loop
ran once per 8 of the exponent, up to half a billion multiplications for
a single number.
The exponent now stops growing at 10000, far past the 308 a double can
reach, and the remaining digits are still consumed.
---
src/lib/eina/eina_convert.c | 4 +++-
src/tests/eina/eina_test_convert.c | 5 +++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/lib/eina/eina_convert.c b/src/lib/eina/eina_convert.c
index 422459c00c..6766525bde 100644
--- a/src/lib/eina/eina_convert.c
+++ b/src/lib/eina/eina_convert.c
@@ -603,7 +603,9 @@ eina_convert_strtod_c(const char *nptr, char **endptr)
for (; isdigit(*iter); iter++)
{
- expo_part = expo_part * 10U + (unsigned int)(*iter - '0');
+ /* far past any double's range, more digits change nothing */
+ if (expo_part < 10000U)
+ expo_part = expo_part * 10U + (unsigned int)(*iter - '0');
}
}
else if (!isdigit(*(a - 1)))
diff --git a/src/tests/eina/eina_test_convert.c b/src/tests/eina/eina_test_convert.c
index 0824d86656..7ea15223d4 100644
--- a/src/tests/eina/eina_test_convert.c
+++ b/src/tests/eina/eina_test_convert.c
@@ -248,6 +248,11 @@ EFL_START_TEST(eina_convert_strtod_c_simple)
_eina_convert_strtod_c_check("2.2250738585072012e-308");
_eina_convert_strtod_c_check("2.2250738585072013e-308");
_eina_convert_strtod_c_check("2.2250738585072014e-308");
+ /* exponents past UINT_MAX */
+ _eina_convert_strtod_c_check("1e4294967295");
+ _eina_convert_strtod_c_check("1e4294967297");
+ _eina_convert_strtod_c_check("1e-4294967297");
+ _eina_convert_strtod_c_check("1e56789012345678901234567890");
_eina_convert_strtod_c_check(" NaNfoo");
_eina_convert_strtod_c_check(" -INFfoo");
// this test isn't viable because libc actually fails the conversion (testing
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.