diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-03-04 13:59:52 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-03-04 16:37:57 +0100 |
commit | 3820a5c093bcc69e277e6326464749c151031046 (patch) | |
tree | c02c8bea356839414f0c739835280d43e2911ddb /sal | |
parent | dc05428405fb96f28b2d7c7bcfa9033f3f5248a3 (diff) |
ofz#21036: Avoid UBSan signed-integer-overflow in external/dtoa
> workdir/UnpackedTarball/dtoa/src/dtoa.c:3624:12: runtime error: signed integer overflow: 10 * 858993459 cannot be represented in type 'int'
> #0 in strtod_nolocale at workdir/UnpackedTarball/dtoa/src/dtoa.c:3624:12 (instdir/program/libuno_sal.so.3 +0x55286d)
> #1 in double (anonymous namespace)::stringToDouble<char16_t>(char16_t const*, char16_t const*, char16_t, char16_t, rtl_math_ConversionStatus*, char16_t const**) at sal/rtl/math.cxx:976:20 (instdir/program/libuno_sal.so.3 +0x3b5f0e)
> #2 in rtl_math_uStringToDouble at sal/rtl/math.cxx:1028:12 (instdir/program/libuno_sal.so.3 +0x3b1714)
[...]
Change-Id: If24fca1fb4829ddd763c9920a1af9a90dc2b138c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/89966
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sal')
-rw-r--r-- | sal/qa/rtl/math/test-rtl-math.cxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx index 5dab92b81ba8..af45eded639e 100644 --- a/sal/qa/rtl/math/test-rtl-math.cxx +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -180,6 +180,11 @@ public: CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); CPPUNIT_ASSERT_EQUAL(sal_Int32(9), end); CPPUNIT_ASSERT_EQUAL(1E308, res); + + res = rtl::math::stringToDouble(OUString("1E8589934590"), '.', ',', &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_OutOfRange, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(12), end); + CPPUNIT_ASSERT_EQUAL(std::numeric_limits<double>::infinity(), res); } void test_stringToDouble_bad() { |