forcepoint #5 check for short read

a zip file within a structured storage stream. underlying storage stream
claims larger size that it can satisfy on read

Change-Id: I8516b12df33ad78b2525192826f5e3aef2622eb8
Reviewed-on: https://gerrit.libreoffice.org/50238
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2018-02-23 12:53:34 +00:00
parent e2d8e2e0e2
commit ff6def51db

View File

@ -838,11 +838,14 @@ sal_Int32 ZipFile::findEND()
nEnd = nPos >= 0 ? nPos : 0 ;
aGrabber.seek( nEnd );
aGrabber.readBytes ( aBuffer, nLength - nEnd );
auto nSize = nLength - nEnd;
if (nSize != aGrabber.readBytes(aBuffer, nSize))
throw ZipException("Zip END signature not found!" );
const sal_Int8 *pBuffer = aBuffer.getConstArray();
nPos = nLength - nEnd - ENDHDR;
nPos = nSize - ENDHDR;
while ( nPos >= 0 )
{
if (pBuffer[nPos] == 'P' && pBuffer[nPos+1] == 'K' && pBuffer[nPos+2] == 5 && pBuffer[nPos+3] == 6 )