[openoffice.org/f14/master] Resolves: rhbz#656191 catch bad_alloc when opening corrupt zips

Caolan McNamara caolanm at fedoraproject.org
Thu Nov 25 16:49:10 UTC 2010


commit 3189c10c99c267e1942a64e82b7620ab1feb3020
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Nov 25 16:49:07 2010 +0000

    Resolves: rhbz#656191 catch bad_alloc when opening corrupt zips

 ...bz-656191-Catch-bad-alloc-and-convert-to-.patch |   73 ++++++++++++++++++++
 openoffice.org.spec                                |    7 ++-
 2 files changed, 79 insertions(+), 1 deletions(-)
---
diff --git a/0001-Resolves-rhbz-656191-Catch-bad-alloc-and-convert-to-.patch b/0001-Resolves-rhbz-656191-Catch-bad-alloc-and-convert-to-.patch
new file mode 100644
index 0000000..5987fd5
--- /dev/null
+++ b/0001-Resolves-rhbz-656191-Catch-bad-alloc-and-convert-to-.patch
@@ -0,0 +1,73 @@
+From 047a986e3af855cdb4c27274da5a10fb5da37fb6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm at redhat.com>
+Date: Thu, 25 Nov 2010 16:46:43 +0000
+Subject: [PATCH] Resolves: rhbz#656191 Catch bad alloc and convert to ZipIOException
+
+---
+ package/source/zipapi/ZipFile.cxx |   45 ++++++++++++++++++++++--------------
+ 1 files changed, 27 insertions(+), 18 deletions(-)
+
+diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
+index 7768470..0cfb519 100644
+--- a/package/source/zipapi/ZipFile.cxx
++++ b/package/source/zipapi/ZipFile.cxx
+@@ -638,29 +638,38 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
+     aGrabber >> nExtraLen;
+     rEntry.nOffset = static_cast < sal_Int32 > (aGrabber.getPosition()) + nPathLen + nExtraLen;
+ 
+-    // read always in UTF8, some tools seem not to set UTF8 bit
+-    uno::Sequence < sal_Int8 > aNameBuffer( nPathLen );
+-    sal_Int32 nRead = aGrabber.readBytes( aNameBuffer, nPathLen );
+-    if ( nRead < aNameBuffer.getLength() )
+-            aNameBuffer.realloc( nRead );
++    sal_Bool bBroken = sal_False;
+ 
+-    ::rtl::OUString sLOCPath = rtl::OUString::intern( (sal_Char *) aNameBuffer.getArray(),
+-                                                        aNameBuffer.getLength(),
+-                                                        RTL_TEXTENCODING_UTF8 );
++    try
++    {
++        // read always in UTF8, some tools seem not to set UTF8 bit
++        uno::Sequence < sal_Int8 > aNameBuffer( nPathLen );
++        sal_Int32 nRead = aGrabber.readBytes( aNameBuffer, nPathLen );
++        if ( nRead < aNameBuffer.getLength() )
++                aNameBuffer.realloc( nRead );
++
++        ::rtl::OUString sLOCPath = rtl::OUString::intern( (sal_Char *) aNameBuffer.getArray(),
++                                                            aNameBuffer.getLength(),
++                                                            RTL_TEXTENCODING_UTF8 );
++
++        if ( rEntry.nPathLen == -1 ) // the file was created
++        {
++            rEntry.nPathLen = nPathLen;
++            rEntry.sPath = sLOCPath;
++        }
+ 
+-    if ( rEntry.nPathLen == -1 ) // the file was created
++        // the method can be reset for internal use so it is not checked
++        bBroken = rEntry.nVersion != nVersion
++                        || rEntry.nFlag != nFlag
++                        || rEntry.nTime != nTime
++                        || rEntry.nPathLen != nPathLen
++                        || !rEntry.sPath.equals( sLOCPath );
++    }
++    catch(::std::bad_alloc &)
+     {
+-        rEntry.nPathLen = nPathLen;
+-        rEntry.sPath = sLOCPath;
++        bBroken = sal_True;
+     }
+ 
+-    // the method can be reset for internal use so it is not checked
+-    sal_Bool bBroken = rEntry.nVersion != nVersion
+-                    || rEntry.nFlag != nFlag
+-                    || rEntry.nTime != nTime
+-                    || rEntry.nPathLen != nPathLen
+-                    || !rEntry.sPath.equals( sLOCPath );
+-
+     if ( bBroken && !bRecoveryMode )
+         throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ),
+                             Reference< XInterface >() );
+-- 
+1.7.3.2
+
diff --git a/openoffice.org.spec b/openoffice.org.spec
index 48d2b29..9b1c05e 100644
--- a/openoffice.org.spec
+++ b/openoffice.org.spec
@@ -1,6 +1,6 @@
 %define oootag OOO330
 %define ooomilestone 16
-%define rh_rpm_release 4
+%define rh_rpm_release 5
 
 # rhbz#465664 jar-repacking breaks help by reordering META-INF/MANIFEST.MF
 %define __jar_repack %{nil}
@@ -142,6 +142,7 @@ Patch58: rhbz650170.quickstarter.safeexit.patch
 Patch59: 0001-initial-commit-for-vba-blob-not-including-container_.patch
 Patch60: 0001-we-see-stacktraces-with-this-NULL-sometimes.patch
 Patch61: exit.quickstarter.when.deleted.patch
+Patch62: 0001-Resolves-rhbz-656191-Catch-bad-alloc-and-convert-to-.patch
 
 %{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 %define instdir %{_libdir}
@@ -1700,6 +1701,7 @@ cp -p %{SOURCE5} external/unowinreg/unowinreg.dll
 %patch59 -p1 -b .vba-blob-not-including-container_.patch
 %patch60 -p1 -b .0001-we-see-stacktraces-with-this-NULL-sometimes.patch
 %patch61 -p1 -b .exit.quickstarter.when.deleted.patch
+%patch62 -p1 -b .rhbz656191-Catch-bad-alloc-and-convert-to-.patch
 touch scripting/source/pyprov/delzip
 touch scripting/util/provider/beanshell/delzip
 touch scripting/util/provider/javascript/delzip
@@ -3872,6 +3874,9 @@ unopkg remove --shared org.openoffice.legacy.ScriptProviderForPython.zip > /dev/
 %endif
 
 %changelog
+* Thu Nov 26 2010 Caolán McNamara <caolanm at redhat.com>- 1:3.3.0-16.5
+- Resolves: rhbz#656191 catch bad_alloc when opening corrupt zips
+
 * Thu Nov 25 2010 Caolán McNamara <caolanm at redhat.com>- 1:3.3.0-16.4
 - Resolves: rhbz#610103 exit quickstarter when libs deleted
 


More information about the scm-commits mailing list