summaryrefslogtreecommitdiff
path: root/package/source
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2011-01-07 20:06:19 +0100
committerPetr Mladek <pmladek@suse.cz>2011-01-07 20:06:19 +0100
commit7100d5b93b4f49ab36f9105bc112cadf55812a41 (patch)
tree287d1d3618ab1820bc4fbeb7255a6e2002a7b98a /package/source
parente4375b5e4312202fc1166ac5a10bb39b2e604fad (diff)
parentdbc6f094895662a648c2b7e55a62d53fbda279ca (diff)
Merge commit 'ooo/OOO330_m19' into libreoffice-3-3
Diffstat (limited to 'package/source')
-rw-r--r--package/source/zipapi/ZipFile.cxx9
1 files changed, 7 insertions, 2 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx
index b4ee15e5f527..e83d824c3d87 100644
--- a/package/source/zipapi/ZipFile.cxx
+++ b/package/source/zipapi/ZipFile.cxx
@@ -843,13 +843,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 )
{