[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 3 commits - package/source
Thorsten Behrens
thorsten at kemper.freedesktop.org
Fri Dec 16 00:45:24 PST 2011
package/source/zipapi/ZipFile.cxx | 16 ++++++++--------
package/source/zippackage/ZipPackageFolder.cxx | 12 ++++++------
2 files changed, 14 insertions(+), 14 deletions(-)
New commits:
commit b469cd43117c6269db121207e1be5152907b4dd0
Author: Thorsten Behrens <tbehrens at suse.com>
Date: Fri Dec 16 01:32:43 2011 +0100
Better fix for over-zealous Zip package consistency.
Turns out our encrypted zip package code writes out mismatching
compression methods in central directory and local file headers -
so not only be lenient towards the apple bug (n#653688), but also
ours (i.e. keep not comparing nMethod with nHow).
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 1278f09..16d5a00 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -686,9 +686,15 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
rEntry.sPath = sLOCPath;
}
- // the method can be reset for internal use so it is not checked
+ // check basic local file header / entry consistency, just
+ // plain ignore bits 1 & 2 of the flag field - they are either
+ // purely informative, or even fully undefined (depending on
+ // nMethod)
+ // Do *not* compare nMethod / nHow, older versions with
+ // encrypted streams write mismatching DEFLATE/STORE pairs
+ // there.
bBroken = rEntry.nVersion != nVersion
- || rEntry.nFlag != nFlag
+ || (rEntry.nFlag & ~6L) != (nFlag & ~6L)
|| rEntry.nTime != nTime
|| rEntry.nPathLen != nPathLen
|| !rEntry.sPath.equals( sLOCPath );
commit 8edfcee9f858a94fa62c91d633ced9c185b67cd3
Author: Thorsten Behrens <tbehrens at suse.com>
Date: Fri Dec 16 01:30:22 2011 +0100
Fix inconsistent compression method for encrypted ZIP packages.
While fixing n#653688, turned out we write method=STORED into local
file headers, and method=DEFLATED into central directory structure
for encrypted ODF. Damn side-effects - fixed as hopefully intended
here.
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index 60f5cd1..daee0f4 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -657,16 +657,16 @@ bool ZipPackageFolder::saveChild( const ::rtl::OUString &rShortName, const Conte
rInfo.pStream->SetToBeEncrypted( sal_True );
}
+ // Then copy it back afterwards...
+ ZipPackageFolder::copyZipEntry ( rInfo.pStream->aEntry, *pTempEntry );
+
// Remove hacky bit from entry flags
- if ( pTempEntry->nFlag & ( 1 << 4 ) )
+ if ( rInfo.pStream->aEntry.nFlag & ( 1 << 4 ) )
{
- pTempEntry->nFlag &= ~( 1 << 4 );
- pTempEntry->nMethod = STORED;
+ rInfo.pStream->aEntry.nFlag &= ~( 1 << 4 );
+ rInfo.pStream->aEntry.nMethod = STORED;
}
- // Then copy it back afterwards...
- ZipPackageFolder::copyZipEntry ( rInfo.pStream->aEntry, *pTempEntry );
-
// TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving )
if ( rInfo.pStream->IsEncrypted() )
rInfo.pStream->setSize( nOwnStreamOrigSize );
commit 4dfcdfc3d556ee92992a14e52d04cc9c7ffbe471
Author: Thorsten Behrens <tbehrens at suse.com>
Date: Fri Dec 16 09:41:00 2011 +0100
Revert "Fix n#653688"
This reverts commit bf7f65de1bbd2e12eb68c1c4d68b5193b60f7d3f.
Previous fix broke reading of password-protected documents.
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index 4fd8aea..1278f09 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -688,7 +688,7 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
// the method can be reset for internal use so it is not checked
bBroken = rEntry.nVersion != nVersion
- || rEntry.nMethod != nHow
+ || rEntry.nFlag != nFlag
|| rEntry.nTime != nTime
|| rEntry.nPathLen != nPathLen
|| !rEntry.sPath.equals( sLOCPath );
@@ -698,12 +698,6 @@ sal_Bool ZipFile::readLOC( ZipEntry &rEntry )
bBroken = sal_True;
}
- // ignore bits 1 & 2 for normal deflate algo - they're purely informative
- if( nHow != 8 && nHow != 9 )
- bBroken = bBroken || rEntry.nFlag != nFlag;
- else if( (rEntry.nFlag & ~6L) != (nFlag & ~6L) )
- bBroken = true;
-
if ( bBroken && !bRecoveryMode )
throw ZipIOException( OUString( RTL_CONSTASCII_USTRINGPARAM( "The stream seems to be broken!" ) ),
uno::Reference< XInterface >() );
More information about the Libreoffice-commits
mailing list