summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Lippka ORACLE <christian.lippka@oracle.com>2011-01-05 12:10:11 +0100
committerChristian Lippka ORACLE <christian.lippka@oracle.com>2011-01-05 12:10:11 +0100
commit2c230853f4941b87edc438a6ac0021d1f16730b0 (patch)
tree43fa2e9d54a8e929164daf3a48680738956124e7
parent3e36a47e3877299b34e7e7677f9ca2c4510f1e0a (diff)
impress208: #i115944# fixing large ooxml files
-rw-r--r--package/source/zipapi/ZipFile.cxx10
1 files changed, 7 insertions, 3 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index e95ba9794..3f98eded0 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -836,14 +836,18 @@ sal_Int32 ZipFile::recover()
aGrabber.seek( 0 );
- // TODO/LATER: let the files > 2Gb handle the 2Gb border correctly ( if header is splitted )
- for( sal_Int32 nGenPos = 0; aGrabber.readBytes( aBuffer, SAL_MAX_INT32 ) && aBuffer.getLength() > 30; )
+ const sal_Int32 nToRead = 32000;
+ for( sal_Int32 nGenPos = 0; aGrabber.readBytes( aBuffer, nToRead ) && aBuffer.getLength() > 16; )
{
const sal_Int8 *pBuffer = aBuffer.getConstArray();
sal_Int32 nBufSize = aBuffer.getLength();
sal_Int32 nPos = 0;
- while( nPos < nBufSize - 16 )
+ // the buffer should contain at least one header,
+ // or if it is end of the file, at least the postheader with sizes and hash
+ while( nPos < nBufSize - 30
+ || ( aBuffer.getLength() < nToRead && nPos < nBufSize - 16 ) )
+
{
if ( nPos < nBufSize - 30 && pBuffer[nPos] == 'P' && pBuffer[nPos+1] == 'K' && pBuffer[nPos+2] == 3 && pBuffer[nPos+3] == 4 )
{