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

Caolán McNamara caolanm at redhat.com
Wed Oct 25 13:19:55 UTC 2017


 sw/source/filter/ww8/ww8scan.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit b6dd913802b2078590e8bc31968ce9ccee732df5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Oct 25 09:47:43 2017 +0100

    ofz#3784 check subtract
    
    Change-Id: Ie29385e3ca75f784069400bc63cea7f458985d6f
    Reviewed-on: https://gerrit.libreoffice.org/43811
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 3eceb812aec5..3a3030945306 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -1955,8 +1955,12 @@ sal_Int32 WW8ScannerBase::WW8ReadString( SvStream& rStrm, OUString& rStr,
         if (!bValid)
             break;
 
-        long nLen = ( (nNextPieceCp < nBehindTextCp) ? nNextPieceCp
-            : nBehindTextCp ) - nAktStartCp;
+        WW8_CP nEnd = (nNextPieceCp < nBehindTextCp) ? nNextPieceCp
+            : nBehindTextCp;
+        WW8_CP nLen;
+        const bool bFail = o3tl::checked_sub(nEnd, nAktStartCp, nLen);
+        if (bFail)
+            break;
 
         if( nLen > USHRT_MAX - 1 )
             nLen = USHRT_MAX - 1;


More information about the Libreoffice-commits mailing list