diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-02-23 12:53:34 +0000 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2018-03-06 16:34:03 +0100 |
commit | ce1578c34f5df12169be117af18d92235f160f4b (patch) | |
tree | 59944a03f35fc05859bdd040d2c67f39580edef6 /package | |
parent | f82d02d3faef79f751b638bf06e63a0f836c4d0f (diff) |
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/50240
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
(cherry picked from commit 942e23ac0cf885c8d26884fa1fb17d430f42a5f5)
Diffstat (limited to 'package')
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 3f40df8a0a5f..b855859d4610 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -821,11 +821,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 ) |