Commits

Anonymous committed 992230e

impress208: #i115944# fixing large ooxml files

Comments (0)

Files changed (1)

package/source/zipapi/ZipFile.cxx

 
 		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_Int8 *pBuffer = aBuffer.getConstArray();
-			sal_Int32 nBufSize = aBuffer.getLength();
+		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 )
+            sal_Int32 nPos = 0;
+            // 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 )
 				{