[Libreoffice-commits] core.git: 2 commits - vcl/source

Michael Meeks michael.meeks at suse.com
Tue Mar 5 03:50:33 PST 2013


 vcl/source/filter/FilterConfigCache.cxx |   16 ++++++++++++++++
 vcl/source/filter/FilterConfigCache.hxx |    1 +
 vcl/source/filter/graphicfilter.cxx     |   24 ++++++------------------
 vcl/source/gdi/pngread.cxx              |   13 +++++--------
 4 files changed, 28 insertions(+), 26 deletions(-)

New commits:
commit c123ea35635943bebf87b7515ecf9c9e5b330ffe
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Tue Mar 5 11:48:56 2013 +0000

    make vcl filter config extension search cleaner and more comprehensive
    
    Change-Id: I7a5740b42490bf2301e6466f056fdb1dae4c6dbb

diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx
index 53d0ef8..c3873c3 100644
--- a/vcl/source/filter/FilterConfigCache.cxx
+++ b/vcl/source/filter/FilterConfigCache.cxx
@@ -333,6 +333,22 @@ sal_uInt16 FilterConfigCache::GetImportFormatNumber( const String& rFormatName )
     return sal::static_int_cast< sal_uInt16 >(aIter == aImport.end() ? GRFILTER_FORMAT_NOTFOUND : aIter - aImport.begin());
 }
 
+/// get the index of the filter that matches this extension
+sal_uInt16 FilterConfigCache::GetImportFormatNumberForExtension( const String& rExt )
+{
+    CacheVector::iterator aIter( aImport.begin() );
+    while ( aIter != aImport.end() )
+    {
+        for ( sal_Int32 i = 0; i < aIter->lExtensionList.getLength(); i++ )
+        {
+            if ( aIter->lExtensionList[i].equalsIgnoreAsciiCase( rExt ) )
+                return sal::static_int_cast< sal_uInt16 >( aIter - aImport.begin() );
+        }
+        aIter++;
+    }
+    return GRFILTER_FORMAT_NOTFOUND;
+}
+
 sal_uInt16 FilterConfigCache::GetImportFormatNumberForMediaType( const String& rMediaType )
 {
     CacheVector::iterator aIter( aImport.begin() );
diff --git a/vcl/source/filter/FilterConfigCache.hxx b/vcl/source/filter/FilterConfigCache.hxx
index df1cc10..5a5557a 100644
--- a/vcl/source/filter/FilterConfigCache.hxx
+++ b/vcl/source/filter/FilterConfigCache.hxx
@@ -89,6 +89,7 @@ public:
     sal_uInt16  GetImportFormatNumberForMediaType( const String& rMediaType );
     sal_uInt16  GetImportFormatNumberForShortName( const String& rShortName );
     sal_uInt16  GetImportFormatNumberForTypeName( const String& rType );
+    sal_uInt16  GetImportFormatNumberForExtension( const String& rExt );
     String      GetImportFilterName( sal_uInt16 nFormat );
     String      GetImportFormatName( sal_uInt16 nFormat );
     String      GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry = 0);
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index cd62da4..d1835d0 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -787,8 +787,6 @@ static sal_Bool ImpPeekGraphicFormat( SvStream& rStream, String& rFormatExtensio
 
 sal_uInt16 GraphicFilter::ImpTestOrFindFormat( const String& rPath, SvStream& rStream, sal_uInt16& rFormat )
 {
-    sal_uInt16 n = pConfig->GetImportFormatCount();
-
     // ggf. Filter bzw. Format durch anlesen ermitteln,
     // oder durch anlesen zusichern, dass das Format stimmt:
     if( rFormat == GRFILTER_FORMAT_DONTKNOW )
@@ -796,27 +794,17 @@ sal_uInt16 GraphicFilter::ImpTestOrFindFormat( const String& rPath, SvStream& rS
         String aFormatExt;
         if( ImpPeekGraphicFormat( rStream, aFormatExt, sal_False ) )
         {
-            for( sal_uInt16 i = 0; i < n; i++ )
-            {
-                if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aFormatExt ) )
-                {
-                    rFormat = i;
-                    return GRFILTER_OK;
-                }
-            }
+            rFormat = pConfig->GetImportFormatNumberForExtension( aFormatExt );
+            if( rFormat != GRFILTER_FORMAT_DONTKNOW )
+                return GRFILTER_OK;
         }
         // ggf. Filter anhand der Datei-Endung raussuchen:
         if( rPath.Len() )
         {
             String aExt( ImpGetExtension( rPath ) );
-            for( sal_uInt16 i = 0; i < n; i++ )
-            {
-                if( pConfig->GetImportFormatExtension( i ).EqualsIgnoreCaseAscii( aExt ) )
-                {
-                    rFormat = i;
-                    return GRFILTER_OK;
-                }
-            }
+            rFormat = pConfig->GetImportFormatNumberForExtension( aExt );
+            if( rFormat != GRFILTER_FORMAT_DONTKNOW )
+                return GRFILTER_OK;
         }
         return GRFILTER_FORMATERROR;
     }
commit 0b789377ffc1a05b6c6a58e373900e378835e07e
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Tue Mar 5 11:48:32 2013 +0000

    fdo#61847 - tolerate invalid pngs.
    
    Change-Id: I02a6460e9fa50c1c11e4f4c972bf962064d57410

diff --git a/vcl/source/gdi/pngread.cxx b/vcl/source/gdi/pngread.cxx
index 17cc412..bafafd5 100644
--- a/vcl/source/gdi/pngread.cxx
+++ b/vcl/source/gdi/pngread.cxx
@@ -259,12 +259,10 @@ bool PNGReaderImpl::ReadNextChunk()
         mrPNGStream >> mnChunkLen >> mnChunkType;
         rChunkData.nType = mnChunkType;
 
-        // #128377#/#149343# sanity check for chunk length
-        if( mnChunkLen < 0 )
-            return false;
+        // fdo#61847 truncate over-long, trailing chunks
         const sal_Size nStreamPos = mrPNGStream.Tell();
-        if( nStreamPos + mnChunkLen >= mnStreamSize )
-            return false;
+        if( mnChunkLen < 0 || nStreamPos + mnChunkLen >= mnStreamSize )
+            mnChunkLen = mnStreamSize - nStreamPos;
 
         // calculate chunktype CRC (swap it back to original byte order)
         sal_uInt32 nChunkType = mnChunkType;
@@ -339,7 +337,8 @@ BitmapEx PNGReaderImpl::GetBitmapEx( const Size& rPreviewSizeHint )
     }
 
     // parse the remaining chunks
-    while( mbStatus && !mbIDAT && ReadNextChunk() )
+    bool bRetFromNextChunk;
+    while( mbStatus && !mbIDAT && (bRetFromNextChunk = ReadNextChunk()) )
     {
         switch( mnChunkType )
         {
@@ -445,9 +444,7 @@ BitmapEx PNGReaderImpl::GetBitmapEx( const Size& rPreviewSizeHint )
             aRet.SetPrefMapMode( MAP_100TH_MM );
             aRet.SetPrefSize( maPhysSize );
         }
-
     }
-
     return aRet;
 }
 


More information about the Libreoffice-commits mailing list