[Libreoffice-commits] core.git: oox/source

Caolán McNamara caolanm at redhat.com
Fri Nov 24 12:07:12 UTC 2017


 oox/source/docprop/docprophandler.cxx |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

New commits:
commit eca40d828fa8a5d720089cada62719bc8750ca7f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Nov 24 11:13:17 2017 +0000

    ubsan: runtime error: signed integer overflow
    
    Change-Id: I357717d1f7c33842367179a76b2f3b840c8ef758
    Reviewed-on: https://gerrit.libreoffice.org/45217
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/oox/source/docprop/docprophandler.cxx b/oox/source/docprop/docprophandler.cxx
index 7a1b569e2816..9671ab26d2ca 100644
--- a/oox/source/docprop/docprophandler.cxx
+++ b/oox/source/docprop/docprophandler.cxx
@@ -25,6 +25,7 @@
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/xml/sax/SAXException.hpp>
 
+#include <o3tl/safeint.hxx>
 #include <osl/time.h>
 #include <osl/diagnose.h>
 #include <i18nlangtag/languagetag.hxx>
@@ -501,17 +502,22 @@ void SAL_CALL OOXMLDocPropHandler::characters( const OUString& aChars )
                     break;
 
                 case EXTPR_TOKEN( TotalTime ):
-                    try
-                    {
-                        // The TotalTime is in mins as per ECMA specification.
-                        m_xDocProp->setEditingDuration( aChars.toInt32() * 60 );
-                    }
-                    catch (lang::IllegalArgumentException &)
+                {
+                    sal_Int32 nDuration;
+                    if (!o3tl::checked_multiply<sal_Int32>(aChars.toInt32(), 60, nDuration))
                     {
-                        // ignore
+                        try
+                        {
+                            // The TotalTime is in mins as per ECMA specification.
+                            m_xDocProp->setEditingDuration(nDuration);
+                        }
+                        catch (const lang::IllegalArgumentException&)
+                        {
+                            // ignore
+                        }
                     }
                     break;
-
+                }
                 case EXTPR_TOKEN( Characters ):
                 case EXTPR_TOKEN( CharactersWithSpaces ):
                 case EXTPR_TOKEN( Pages ):


More information about the Libreoffice-commits mailing list