[Libreoffice-commits] core.git: Branch 'libreoffice-5-0-4' - lotuswordpro/source

Caolán McNamara caolanm at redhat.com
Mon Dec 14 08:19:47 PST 2015


 lotuswordpro/source/filter/lwpdoc.cxx         |    8 ++++----
 lotuswordpro/source/filter/lwpframelayout.cxx |    2 +-
 lotuswordpro/source/filter/lwpobj.cxx         |    3 ++-
 lotuswordpro/source/filter/lwpobj.hxx         |   14 +++++++++++++-
 lotuswordpro/source/filter/lwppagelayout.cxx  |    2 +-
 5 files changed, 21 insertions(+), 8 deletions(-)

New commits:
commit ea854163776df3b93ac3ab281babff8f05553bc5
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Thu Dec 10 10:00:58 2015 +0000

    guard against infinite recursion on parsing objects
    
    Change-Id: Ia6502afde54dbf379bc9951c80c6594f1f436ef5
    (cherry picked from commit fbd329800340a496def839181858964b1e3709a5)
    Reviewed-on: https://gerrit.libreoffice.org/20579
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>
    (cherry picked from commit 564687e728c98fec5ba6ffa39007793b2b4aa4e8)
    Reviewed-on: https://gerrit.libreoffice.org/20697
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/lotuswordpro/source/filter/lwpdoc.cxx b/lotuswordpro/source/filter/lwpdoc.cxx
index c93b668..a0dc530 100644
--- a/lotuswordpro/source/filter/lwpdoc.cxx
+++ b/lotuswordpro/source/filter/lwpdoc.cxx
@@ -166,7 +166,7 @@ void LwpDocument::Parse(IXFStream* pOutputStream)
     rtl::Reference<LwpObject> pDocSock = GetSocket().obj( VO_DOCSOCK );
     if(pDocSock.is())
     {
-        pDocSock->Parse(pOutputStream);
+        pDocSock->DoParse(pOutputStream);
     }
 }
 
@@ -412,7 +412,7 @@ void LwpDocument::ParseDocContent(IXFStream* pOutputStream)
         return;
     }
     pLayoutObj->SetFoundry(m_pFoundry);
-    pLayoutObj->Parse(pOutputStream);
+    pLayoutObj->DoParse(pOutputStream);
 }
 
 /**
@@ -795,11 +795,11 @@ void LwpDocSock::Parse(IXFStream* pOutputStream)
 {
     rtl::Reference<LwpObject> pDoc = GetChildHead().obj();
     if(pDoc.is())
-        pDoc->Parse(pOutputStream);
+        pDoc->DoParse(pOutputStream);
 
     pDoc = GetNext().obj();
     if(pDoc.is())
-        pDoc->Parse(pOutputStream);
+        pDoc->DoParse(pOutputStream);
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index 47a5614..feff262 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -1155,7 +1155,7 @@ void LwpDropcapLayout::Parse(IXFStream* pOutputStream)
     if(pPara.is())
     {
         pPara->SetFoundry(m_pFoundry);
-        pPara->Parse(pOutputStream);
+        pPara->DoParse(pOutputStream);
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpobj.cxx b/lotuswordpro/source/filter/lwpobj.cxx
index 010b60e..be9a07f 100644
--- a/lotuswordpro/source/filter/lwpobj.cxx
+++ b/lotuswordpro/source/filter/lwpobj.cxx
@@ -64,7 +64,8 @@
  * @descr  construct lwpobject from stream
  */
 LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm)
-    : m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr), m_pStrm(pStrm), m_bRegisteringStyle(false)
+    : m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr)
+    , m_pStrm(pStrm), m_bRegisteringStyle(false), m_bParsingStyle(false)
 {
     m_pObjStrm = new LwpObjectStream(pStrm, m_ObjHdr.IsCompressed(),
             static_cast<sal_uInt16>(m_ObjHdr.GetSize()) );
diff --git a/lotuswordpro/source/filter/lwpobj.hxx b/lotuswordpro/source/filter/lwpobj.hxx
index 23ed6b2..978bc49 100644
--- a/lotuswordpro/source/filter/lwpobj.hxx
+++ b/lotuswordpro/source/filter/lwpobj.hxx
@@ -95,9 +95,11 @@ protected:
     LwpFoundry* m_pFoundry;
     LwpSvStream* m_pStrm;
     bool m_bRegisteringStyle;
+    bool m_bParsingStyle;
 protected:
     virtual void Read();
     virtual void RegisterStyle();
+    virtual void Parse(IXFStream* pOutputStream);
 public:
     void QuickRead();
     //calls RegisterStyle but bails if DoRegisterStyle is called
@@ -110,7 +112,17 @@ public:
         RegisterStyle();
         m_bRegisteringStyle = false;
     }
-    virtual void Parse(IXFStream* pOutputStream);
+    //calls Parse but bails if DoParse is called
+    //on the same object recursively
+    void DoParse(IXFStream* pOutputStream)
+    {
+        if (m_bParsingStyle)
+            throw std::runtime_error("recursion in parsing");
+        m_bParsingStyle = true;
+        Parse(pOutputStream);
+        m_bParsingStyle = false;
+    }
+
     virtual void XFConvert(XFContentContainer* pCont);
 
     LwpFoundry* GetFoundry(){return m_pFoundry;}
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index 5604863..0f78899 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -127,7 +127,7 @@ void LwpPageLayout::Parse(IXFStream* pOutputStream)
     if(pStory.is())
     {
         pStory->SetFoundry(m_pFoundry);
-        pStory->Parse(pOutputStream);   //Do not parse the next story
+        pStory->DoParse(pOutputStream);   //Do not parse the next story
     }
 }
 


More information about the Libreoffice-commits mailing list