[Libreoffice-commits] .: filter/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed Oct 20 06:05:01 PDT 2010


 filter/source/graphicfilter/itiff/itiff.cxx |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit 22ebfb78e5814fdcf2c783b944c2937c29549c3f
Author: Harri Pitkänen <hatapitk at iki.fi>
Date:   Wed Oct 20 14:01:54 2010 +0100

    #i93300# Don't crash on unsupported .tiffs

diff --git a/filter/source/graphicfilter/itiff/itiff.cxx b/filter/source/graphicfilter/itiff/itiff.cxx
index d2c0b60..cd1678a 100644
--- a/filter/source/graphicfilter/itiff/itiff.cxx
+++ b/filter/source/graphicfilter/itiff/itiff.cxx
@@ -310,6 +310,8 @@ void TIFFReader::ReadTagData( USHORT nTagType, sal_uInt32 nDataLen)
         case 0x0102:   // Bits Per Sample
             nBitsPerSample = ReadIntData();
             OOODEBUG("BitsPerSample",nBitsPerSample);
+            if ( nBitsPerSample >= 32 ) // 32 bit and larger samples are not supported
+                bStatus = FALSE;
             break;
 
         case 0x0103:   // Compression
@@ -462,7 +464,7 @@ void TIFFReader::ReadTagData( USHORT nTagType, sal_uInt32 nDataLen)
         case 0x0140: { // Color Map
             USHORT nVal;
             ULONG i;
-            nNumColors= ( 1 << nBitsPerSample );
+            nNumColors= ( 1UL << nBitsPerSample );
             if ( nDataType == 3 && nNumColors <= 256)
             {
                 pColorMap = new ULONG[ 256 ];
@@ -489,6 +491,13 @@ void TIFFReader::ReadTagData( USHORT nTagType, sal_uInt32 nDataLen)
             OOODEBUG("ColorMap (Anzahl Farben:)", nNumColors);
             break;
         }
+
+        case 0x0153: { // SampleFormat
+            ULONG nSampleFormat = ReadIntData();
+            if ( nSampleFormat == 3 ) // IEEE floating point samples are not supported yet
+                bStatus = FALSE;
+            break;
+        }
     }
 
     if ( pTIFF->GetError() )
@@ -1037,7 +1046,7 @@ void TIFFReader::MakePalCol( void )
             pColorMap = new ULONG[ 256 ];
         if ( nPhotometricInterpretation <= 1 )
         {
-            nNumColors = 1 << nBitsPerSample;
+            nNumColors = 1UL << nBitsPerSample;
             if ( nNumColors > 256 )
                 nNumColors = 256;
             pAcc->SetPaletteEntryCount( (USHORT)nNumColors );
@@ -1238,7 +1247,10 @@ BOOL TIFFReader::ReadTIFF(SvStream & rTIFF, Graphic & rGraphic )
             if ( bStatus )
             {
                 if ( nMaxSampleValue == 0 )
-                    nMaxSampleValue = ( 1 << nBitsPerSample ) - 1;
+                    nMaxSampleValue = ( 1UL << nBitsPerSample ) - 1;
+
+                if ( nMaxSampleValue <= nMinSampleValue )
+                    bStatus = FALSE;
 
                 if ( nPhotometricInterpretation == 2 || nPhotometricInterpretation == 5 || nPhotometricInterpretation == 6 )
                     nDstBitsPerPixel = 24;


More information about the Libreoffice-commits mailing list