diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-12-27 18:38:42 +0000 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2018-01-03 16:59:57 +0100 |
commit | 6a40c4e0ddf606f2fac776764eede2fb5ccde354 (patch) | |
tree | 01d702eab825fa187eb89ae9f663d61b0fbbd526 /package | |
parent | ffca194466e08691e381d642b07154121edefece (diff) |
ofz#4806 Infinite loop
Change-Id: I89a24fa3ce4034ef207233b96c5e26a7b7787444
Reviewed-on: https://gerrit.libreoffice.org/47101
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'package')
-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 |