[Libreoffice-commits] core.git: filter/qa filter/source

Caolán McNamara caolanm at redhat.com
Mon Jul 20 01:22:03 PDT 2015


 filter/qa/cppunit/data/tiff/fail/hang-5.tiff |binary
 filter/source/graphicfilter/itiff/itiff.cxx  |    7 +++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

New commits:
commit 33d43205c341e0cce36b6a1b3082c3927490cbde
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Jul 20 09:20:33 2015 +0100

    test that nNumStripByteCounts value is within bounds of file
    
    Change-Id: If119628d7f510a7db30ed2180111063781cde887

diff --git a/filter/qa/cppunit/data/tiff/fail/hang-5.tiff b/filter/qa/cppunit/data/tiff/fail/hang-5.tiff
new file mode 100644
index 0000000..f1be3fa
Binary files /dev/null and b/filter/qa/cppunit/data/tiff/fail/hang-5.tiff differ
diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index 7a5d487..89de8e0 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -422,14 +422,17 @@ void TIFFReader::ReadTagData( sal_uInt16 nTagType, sal_uInt32 nDataLen)
                 nNumStripByteCounts = 0; // to be on the safe side
             nOldNumSBC = nNumStripByteCounts;
             nDataLen += nOldNumSBC;
-            if ( ( nDataLen > nOldNumSBC ) && ( nDataLen < SAL_MAX_UINT32 / sizeof( sal_uInt32 ) ) )
+            size_t nMaxAllocAllowed = SAL_MAX_UINT32 / sizeof(sal_uInt32);
+            size_t nMaxRecordsAvailable = pTIFF->remainingSize() / DataTypeSize();
+            if (nDataLen > nOldNumSBC && nDataLen < nMaxAllocAllowed &&
+                (nDataLen - nOldNumSBC) <= nMaxRecordsAvailable)
             {
                 nNumStripByteCounts = nDataLen;
                 try
                 {
                     pStripByteCounts = new sal_uLong[ nNumStripByteCounts ];
                 }
-                    catch (const std::bad_alloc &)
+                catch (const std::bad_alloc &)
                 {
                     pStripByteCounts = NULL;
                     nNumStripByteCounts = 0;


More information about the Libreoffice-commits mailing list