diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-11-05 21:52:29 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-11-06 12:29:18 +0100 |
commit | 7351bf23f5f92b1e59436b3f7b99ed52ab03bf4e (patch) | |
tree | dbe37cb4146c520d408cfb18651290deadc6cf75 /vcl/source | |
parent | 1b2fa783af31cf3ae030dd9dc55cbcb7dd4c7220 (diff) |
ofz#52685 Timeout
only allow a short read after reading the preamble of the tiff
Change-Id: Idd4b8892457566daa028c68125fe3beeb7499803
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142346
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/filter/itiff/itiff.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx index 510261e21b91..3e308f3019d3 100644 --- a/vcl/source/filter/itiff/itiff.cxx +++ b/vcl/source/filter/itiff/itiff.cxx @@ -39,11 +39,11 @@ namespace { SvStream& rStream; tsize_t nSize; - int nShortReads; + bool bAllowOneShortRead; Context(SvStream& rInStream, tsize_t nInSize) : rStream(rInStream) , nSize(nInSize) - , nShortReads(0) + , bAllowOneShortRead(false) { } }; @@ -55,10 +55,10 @@ static tsize_t tiff_read(thandle_t handle, tdata_t buf, tsize_t size) tsize_t nRead = pContext->rStream.ReadBytes(buf, size); // tdf#149417 allow one short read, which is similar to what // we do for jpeg since tdf#138950 - if (nRead < size && !pContext->nShortReads) + if (nRead < size && pContext->bAllowOneShortRead) { memset(static_cast<char*>(buf) + nRead, 0, size - nRead); - ++pContext->nShortReads; + pContext->bAllowOneShortRead = false; return size; } return nRead; @@ -190,6 +190,7 @@ bool ImportTiffGraphicImport(SvStream& rTIFF, Graphic& rGraphic) break; std::vector<uint32_t> raster(nPixelsRequired); + aContext.bAllowOneShortRead = true; if (TIFFReadRGBAImageOriented(tif, w, h, raster.data(), ORIENTATION_TOPLEFT, 1)) { Bitmap bitmap(Size(w, h), vcl::PixelFormat::N24_BPP); |