From de907deeac388b31e5953d472d3dc8d3877c60c6 Mon Sep 17 00:00:00 2001 From: RĂ¼diger Timm Date: Tue, 8 Jul 2008 07:28:23 +0000 Subject: INTEGRATION: CWS fwk90 (1.48.12); FILE MERGED 2008/06/08 15:23:26 mav 1.48.12.1: #i88946# fix reparing of encrypted documents --- package/source/zipapi/ZipFile.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'package') diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index a2873ff5cf8d..17c06512c42c 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: ZipFile.cxx,v $ - * $Revision: 1.49 $ + * $Revision: 1.50 $ * * This file is part of OpenOffice.org. * @@ -876,14 +876,24 @@ sal_Int32 ZipFile::recover() for( EntryHash::iterator aIter = aEntries.begin(); aIter != aEntries.end(); aIter++ ) { ZipEntry aTmp = (*aIter).second; - if( (*aIter).second.nMethod == DEFLATED && (*aIter).second.nFlag & 8 ) + + // this is a broken package, accept this block not only for DEFLATED streams + if( (*aIter).second.nFlag & 8 ) { sal_Int32 nStreamOffset = nGenPos + nPos - nCompressedSize; if ( nStreamOffset == (*aIter).second.nOffset && nCompressedSize > (*aIter).second.nCompressedSize ) { - sal_Int32 nRealSize = 0, nRealCRC = 0; - getSizeAndCRC( nStreamOffset, nCompressedSize, &nRealSize, &nRealCRC ); - if ( nRealSize == nSize && nRealCRC == nCRC32 ) + // only DEFLATED blocks need to be checked + sal_Bool bAcceptBlock = ( (*aIter).second.nMethod == STORED && nCompressedSize == nSize ); + + if ( !bAcceptBlock ) + { + sal_Int32 nRealSize = 0, nRealCRC = 0; + getSizeAndCRC( nStreamOffset, nCompressedSize, &nRealSize, &nRealCRC ); + bAcceptBlock = ( nRealSize == nSize && nRealCRC == nCRC32 ); + } + + if ( bAcceptBlock ) { (*aIter).second.nCrc = nCRC32; (*aIter).second.nCompressedSize = nCompressedSize; -- cgit v1.2.3