summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorNoel <noelgrandin@gmail.com>2020-11-16 15:58:10 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-18 06:54:06 +0100
commit8c9a4ff511a3b1d84a7a6d08a1b153c07f164abb (patch)
tree9bf5454718b572c33ccea18ae0c7cd6743d4381d /lotuswordpro
parent6610266bde5a836d8ee1bfec6c8ab9d30c1d2529 (diff)
throw exception in SvStream when reading past end of file
to avoid chasing weird problems where we read past the end of file, which leads to random data in the variable we read into. I expect a couple of possible regressions from this change (1) memory leaks caused by non-exception-safe memory handling. Of which there should not be much because we're pretty good about using smart pointer classes these days. (2) Broken files which used to load, will no longer do so. These will have to be debugged by putting a breakpoint on the SvStreamEOFException constructor, and examining the backtrace to see where we should be catching and ignoring the exception to make the code continue to handle such broken files. Change-Id: I351be031bb083a3484a9a1b650a58892700e6fb7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/105936 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/inc/lwpsvstream.hxx1
-rw-r--r--lotuswordpro/source/filter/lwpobjhdr.cxx3
-rw-r--r--lotuswordpro/source/filter/lwpsvstream.cxx2
3 files changed, 5 insertions, 1 deletions
diff --git a/lotuswordpro/inc/lwpsvstream.hxx b/lotuswordpro/inc/lwpsvstream.hxx
index 9a7271941f71..a962f6e599d6 100644
--- a/lotuswordpro/inc/lwpsvstream.hxx
+++ b/lotuswordpro/inc/lwpsvstream.hxx
@@ -72,6 +72,7 @@ public:
size_t Read(void* bytes, size_t nBytesToRead);
void SeekRel(sal_Int64 pos);
sal_Int64 Tell();
+ sal_uInt64 remainingSize();
sal_Int64 Seek(sal_Int64 pos);
bool CheckSeek(sal_Int64 pos);
diff --git a/lotuswordpro/source/filter/lwpobjhdr.cxx b/lotuswordpro/source/filter/lwpobjhdr.cxx
index 13ade159cd82..aeb5c895fc11 100644
--- a/lotuswordpro/source/filter/lwpobjhdr.cxx
+++ b/lotuswordpro/source/filter/lwpobjhdr.cxx
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*************************************************************************
*
* The Contents of this file are made available subject to the terms of
@@ -105,6 +104,8 @@ bool LwpObjectHeader::Read(LwpSvStream& rStrm)
{
sal_uInt8 nFlagBits = 0;
sal_uInt16 VOType = 0;
+ if (rStrm.remainingSize() < 3)
+ return false;
rStrm.ReadUInt16(VOType);
rStrm.ReadUInt8(nFlagBits);
diff --git a/lotuswordpro/source/filter/lwpsvstream.cxx b/lotuswordpro/source/filter/lwpsvstream.cxx
index c95279a9f846..dfd18168a728 100644
--- a/lotuswordpro/source/filter/lwpsvstream.cxx
+++ b/lotuswordpro/source/filter/lwpsvstream.cxx
@@ -98,6 +98,8 @@ void LwpSvStream::SeekRel(sal_Int64 pos) { m_pStream->SeekRel(pos); }
* @descr Get the current position in stream
*/
sal_Int64 LwpSvStream::Tell() { return m_pStream->Tell(); }
+
+sal_uInt64 LwpSvStream::remainingSize() { return m_pStream->remainingSize(); }
/**
* @descr Seek to pos
*/