[Libreoffice-commits] core.git: 2 commits - lotuswordpro/source

Caolán McNamara caolanm at redhat.com
Tue Apr 25 10:57:03 UTC 2017


 lotuswordpro/source/filter/bencont.cxx |   15 +++++----------
 lotuswordpro/source/filter/bento.hxx   |    3 ++-
 lotuswordpro/source/filter/tocread.cxx |   15 +++++++++------
 3 files changed, 16 insertions(+), 17 deletions(-)

New commits:
commit 825c8f1b6e2c1e8c686f4656337fa2879ade481d
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Apr 25 11:55:07 2017 +0100

    ofz#1270 avoid oom
    
    Change-Id: Iedf0ffdedea1ccda9276763c9d39924c3ff8943b

diff --git a/lotuswordpro/source/filter/bencont.cxx b/lotuswordpro/source/filter/bencont.cxx
index 8d67e3905963..ed15dc9858a6 100644
--- a/lotuswordpro/source/filter/bencont.cxx
+++ b/lotuswordpro/source/filter/bencont.cxx
@@ -332,6 +332,11 @@ void LtcBenContainer::CreateGraphicStream(SvStream * &pStream, const char *pObje
     pStream = pMemStream;
 }
 
+sal_uLong LtcBenContainer::remainingSize() const
+{
+    return m_ulLength - cpStream->Tell();
+}
+
 }// end namespace OpenStormBento
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/bento.hxx b/lotuswordpro/source/filter/bento.hxx
index f5f2408d4036..9471590ed6ef 100644
--- a/lotuswordpro/source/filter/bento.hxx
+++ b/lotuswordpro/source/filter/bento.hxx
@@ -209,6 +209,7 @@ public: // Internal methods
     explicit LtcBenContainer(LwpSvStream * pStream);
     ~LtcBenContainer();
 
+    sal_uLong remainingSize() const;
     BenError Read(void * pBuffer, unsigned long MaxSize,
       unsigned long * pAmtRead);
     BenError ReadKnownSize(void * pBuffer, unsigned long Amt);
diff --git a/lotuswordpro/source/filter/tocread.cxx b/lotuswordpro/source/filter/tocread.cxx
index b6c32955411b..8e7e79a855e4 100644
--- a/lotuswordpro/source/filter/tocread.cxx
+++ b/lotuswordpro/source/filter/tocread.cxx
@@ -267,6 +267,13 @@ CBenTOCReader::ReadTOC()
                     if ((Err = cpContainer->SeekToPosition(Pos)) != BenErr_OK)
                         return Err;
 
+                    const auto nRemainingSize = cpContainer->remainingSize();
+                    if (Length > nRemainingSize)
+                    {
+                        SAL_WARN("lwp", "stream too short for claimed no of records");
+                        Length = nRemainingSize;
+                    }
+
                     #define STACK_BUFFER_SIZE 256
                     char sStackBuffer[STACK_BUFFER_SIZE];
                     char * sAllocBuffer;
commit b79f9a9bc818022a59184113cf20dd5ada29deff
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Apr 25 10:52:21 2017 +0100

    LtcBenContainer::GetSize is always BenErr_OK
    
    Change-Id: Ic14cbc70358800dab57c1a5ac0a834e257d4951a

diff --git a/lotuswordpro/source/filter/bencont.cxx b/lotuswordpro/source/filter/bencont.cxx
index c67610943f51..8d67e3905963 100644
--- a/lotuswordpro/source/filter/bencont.cxx
+++ b/lotuswordpro/source/filter/bencont.cxx
@@ -255,16 +255,6 @@ LtcUtBenValueStream * LtcBenContainer::FindValueStreamWithPropertyName(const cha
 {
     return FindNextValueStreamWithPropertyName(sPropertyName);
 }
-/**
-*   <description>
-*   @param  pointer to length of bento file
-*   @return BenError
-*/
-BenError LtcBenContainer::GetSize(sal_uLong * pLength)
-{
-    *pLength = m_ulLength;
-    return BenErr_OK;
-}
 
 sal_uInt32 GetSvStreamSize(SvStream * pStream)
 {
diff --git a/lotuswordpro/source/filter/bento.hxx b/lotuswordpro/source/filter/bento.hxx
index 5919258ed78d..f5f2408d4036 100644
--- a/lotuswordpro/source/filter/bento.hxx
+++ b/lotuswordpro/source/filter/bento.hxx
@@ -223,7 +223,7 @@ public: // Internal methods
     LtcUtBenValueStream * FindValueStreamWithPropertyName(const char * sPropertyName);
     void CreateGraphicStream(SvStream * &pStream,  const char *pObjectName);
 
-    BenError GetSize(sal_uLong * pLength);
+    sal_uLong GetSize() const { return m_ulLength; }
 private: // Data
     CUtOwningList cObjects;
     CUtList cNamedObjects;
diff --git a/lotuswordpro/source/filter/tocread.cxx b/lotuswordpro/source/filter/tocread.cxx
index c050b11a4e06..b6c32955411b 100644
--- a/lotuswordpro/source/filter/tocread.cxx
+++ b/lotuswordpro/source/filter/tocread.cxx
@@ -72,9 +72,7 @@ CBenTOCReader::ReadLabelAndTOC()
     if ((Err = ReadLabel(&TOCOffset, &cTOCSize)) != BenErr_OK)
         return Err;
 
-    sal_uLong nLength;
-    if ((Err = cpContainer->GetSize(&nLength)) != BenErr_OK)
-        return Err;
+    sal_uLong nLength = cpContainer->GetSize();
 
     if (TOCOffset > nLength)
         return BenErr_ReadPastEndOfTOC;
@@ -148,9 +146,7 @@ CBenTOCReader::SearchForLabel(BenByte * pLabel)
 {
     BenError Err;
 
-    sal_uLong Length;
-    if ((Err = cpContainer->GetSize(&Length)) != BenErr_OK)
-        return Err;
+    sal_uLong Length = cpContainer->GetSize();
 
     // Always ready to check for MagicBytes from
     // CurrOffset - BEN_MAGIC_BYTES_SIZE to CurrOffset - 1


More information about the Libreoffice-commits mailing list