diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2011-01-25 09:58:16 +0100 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2011-01-25 09:58:16 +0100 |
commit | 959f9f9d22b785c43d100353aacd9a4e1c16f82c (patch) | |
tree | 3c0cfff32206a6411ae6a4a1bc6715f982c0e4fb /package | |
parent | CWS-TOOLING: integrate CWS fwk162 (diff) | |
parent | CWS-TOOLING: integrate CWS impress208 (diff) | |
download | core-959f9f9d22b785c43d100353aacd9a4e1c16f82c.tar.gz core-959f9f9d22b785c43d100353aacd9a4e1c16f82c.zip |
#i10000# #i10000# changes from OOO330 m20
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index f01b7ce06f4b..dcd5669897e3 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -836,13 +836,18 @@ sal_Int32 ZipFile::recover() aGrabber.seek( 0 ); - for( sal_Int32 nGenPos = 0; aGrabber.readBytes( aBuffer, 32000 ) && 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 ) { |