summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-06-01 12:40:23 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-06-01 16:03:32 +0200
commitc90db9e43db509bef6892c8443480ffa9ed8bbe0 (patch)
treeb3506da8fdf14ea5902c76ee2285ca656bdd98f1
parent3483df997170378dc44d4f025b960e489e0c7924 (diff)
Resolves: tdf#149417 allow one short read in tiff import as not a failure
Change-Id: I77bff41abd51cfd3050836fff04e9644b0828c09 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135239 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/source/filter/itiff/itiff.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/vcl/source/filter/itiff/itiff.cxx b/vcl/source/filter/itiff/itiff.cxx
index 9c0b6efff6b6..672ef92d902a 100644
--- a/vcl/source/filter/itiff/itiff.cxx
+++ b/vcl/source/filter/itiff/itiff.cxx
@@ -37,9 +37,11 @@ namespace
{
SvStream& rStream;
tsize_t nSize;
+ int nShortReads;
Context(SvStream& rInStream, tsize_t nInSize)
: rStream(rInStream)
, nSize(nInSize)
+ , nShortReads(0)
{
}
};
@@ -48,7 +50,16 @@ namespace
static tsize_t tiff_read(thandle_t handle, tdata_t buf, tsize_t size)
{
Context* pContext = static_cast<Context*>(handle);
- return pContext->rStream.ReadBytes(buf, 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)
+ {
+ memset(static_cast<char*>(buf) + nRead, 0, size - nRead);
+ ++pContext->nShortReads;
+ return size;
+ }
+ return nRead;
}
static tsize_t tiff_write(thandle_t, tdata_t, tsize_t)