diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-27 18:38:42 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-12-27 21:42:12 +0100 |
commit | 84d0b4fcfb74288a8ed22f7786db8368a9a0a807 (patch) | |
tree | 51b6d8d24d55d46080b92ebe95f618d9a977a51c /package/source | |
parent | 5d30798c22fce0a6773bc61dcfbad59dc194bde0 (diff) |
ofz#4806 Infinite loop
Change-Id: I89a24fa3ce4034ef207233b96c5e26a7b7787444
Reviewed-on: https://gerrit.libreoffice.org/47096
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'package/source')
-rw-r--r-- | package/source/zipapi/ZipFile.cxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/package/source/zipapi/ZipFile.cxx b/package/source/zipapi/ZipFile.cxx index 61f7ea1dacc1..de4c1a364acd 100644 --- a/package/source/zipapi/ZipFile.cxx +++ b/package/source/zipapi/ZipFile.cxx @@ -539,6 +539,7 @@ public: const sal_Int32 nBufSize = 8192; sal_Int32 nRemaining = xSrcStream->available(); + sal_Int32 nRead = 0; maBytes.reserve(nRemaining); uno::Sequence<sal_Int8> aBuf(nBufSize); @@ -552,10 +553,17 @@ public: }; while (nRemaining > nBufSize) - nRemaining -= readAndCopy(nBufSize); + { + const auto nBytes = readAndCopy(nBufSize); + if (!nBytes) + break; + nRead += nBytes; + nRemaining -= nBytes; + } if (nRemaining) - readAndCopy(nRemaining); + nRead += readAndCopy(nRemaining); + maBytes.resize(nRead); } virtual sal_Int32 SAL_CALL readBytes( uno::Sequence<sal_Int8>& rData, sal_Int32 nBytesToRead ) override |