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

Caolán McNamara caolanm at redhat.com
Tue Mar 15 09:23:49 UTC 2016


 lotuswordpro/qa/cppunit/data/fail/recurse-2.lwp |binary
 lotuswordpro/source/filter/lwpfootnote.cxx      |    2 +-
 lotuswordpro/source/filter/lwpframelayout.cxx   |    4 ++--
 lotuswordpro/source/filter/lwpfribframe.cxx     |    2 +-
 lotuswordpro/source/filter/lwpnotes.cxx         |    4 ++--
 lotuswordpro/source/filter/lwpobj.cxx           |    1 +
 lotuswordpro/source/filter/lwpobj.hxx           |   14 ++++++++++++--
 lotuswordpro/source/filter/lwppagelayout.cxx    |    4 ++--
 lotuswordpro/source/filter/lwpstory.cxx         |    8 ++++----
 9 files changed, 25 insertions(+), 14 deletions(-)

New commits:
commit 9e0004f2cc64ffa23ecd5c7c82016624eb8a5a20
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Mar 15 09:21:10 2016 +0000

    recurse protection for XFConvert
    
    Change-Id: Ib6008d4b07159acad26c7baeb775702119c12e3b

diff --git a/lotuswordpro/qa/cppunit/data/fail/recurse-2.lwp b/lotuswordpro/qa/cppunit/data/fail/recurse-2.lwp
new file mode 100644
index 0000000..f19b0d7
Binary files /dev/null and b/lotuswordpro/qa/cppunit/data/fail/recurse-2.lwp differ
diff --git a/lotuswordpro/source/filter/lwpfootnote.cxx b/lotuswordpro/source/filter/lwpfootnote.cxx
index 408cb48..ecc5e83 100644
--- a/lotuswordpro/source/filter/lwpfootnote.cxx
+++ b/lotuswordpro/source/filter/lwpfootnote.cxx
@@ -187,7 +187,7 @@ void LwpFootnote::XFConvert(XFContentContainer * pCont)
     LwpContent* pContent = FindFootnoteContent();
     if(pContent)
     {
-        pContent->XFConvert(pCont);
+        pContent->DoXFConvert(pCont);
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpframelayout.cxx b/lotuswordpro/source/filter/lwpframelayout.cxx
index c209cab..7f593e4 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -835,7 +835,7 @@ void LwpFrameLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart
             rtl::Reference<LwpObject> content = m_Content.obj();
             if (content.is())
             {
-                content->XFConvert(pXFFrame);
+                content->DoXFConvert(pXFFrame);
                 //set frame size according to ole size
                 ApplyGraphicSize(pXFFrame);
             }
@@ -1103,7 +1103,7 @@ void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart
 
         while (pLayout && pLayout != this)
         {
-            pLayout->XFConvert(pXFFrame);
+            pLayout->DoXFConvert(pXFFrame);
             pLayout = dynamic_cast<LwpVirtualLayout*>(pLayout->GetNext().obj().get());
         }
 
diff --git a/lotuswordpro/source/filter/lwpfribframe.cxx b/lotuswordpro/source/filter/lwpfribframe.cxx
index 91ee697..a257284 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -180,7 +180,7 @@ void LwpFribFrame::XFConvert(XFContentContainer* pCont)
         }
     }
 
-    pLayout->XFConvert(pXFContentContainer);
+    pLayout->DoXFConvert(pXFContentContainer);
 
     if(m_bRevisionFlag)
     {
diff --git a/lotuswordpro/source/filter/lwpnotes.cxx b/lotuswordpro/source/filter/lwpnotes.cxx
index 1da5922..09b28ec 100644
--- a/lotuswordpro/source/filter/lwpnotes.cxx
+++ b/lotuswordpro/source/filter/lwpnotes.cxx
@@ -181,7 +181,7 @@ void LwpNoteLayout::XFConvert(XFContentContainer * pCont)
     LwpVirtualLayout* pTextLayout = GetTextLayout();
     if(pTextLayout)
     {
-        pTextLayout->XFConvert(pCont);
+        pTextLayout->DoXFConvert(pCont);
     }
 }
 
@@ -290,7 +290,7 @@ void LwpNoteTextLayout::XFConvert(XFContentContainer * pCont)
     rtl::Reference<LwpObject> pContent = m_Content.obj();
     if(pContent.is())
     {
-        pContent->XFConvert(pCont);
+        pContent->DoXFConvert(pCont);
     }
 }
 
diff --git a/lotuswordpro/source/filter/lwpobj.cxx b/lotuswordpro/source/filter/lwpobj.cxx
index 8839702..334c0c1 100644
--- a/lotuswordpro/source/filter/lwpobj.cxx
+++ b/lotuswordpro/source/filter/lwpobj.cxx
@@ -62,6 +62,7 @@
 LwpObject::LwpObject(LwpObjectHeader objHdr, LwpSvStream* pStrm)
     : m_ObjHdr(objHdr), m_pObjStrm(nullptr), m_pFoundry(nullptr)
     , m_pStrm(pStrm), m_bRegisteringStyle(false), m_bParsingStyle(false)
+    , m_bConvertingContent(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 bcd6136..7556a47 100644
--- a/lotuswordpro/source/filter/lwpobj.hxx
+++ b/lotuswordpro/source/filter/lwpobj.hxx
@@ -92,10 +92,12 @@ protected:
     LwpSvStream* m_pStrm;
     bool m_bRegisteringStyle;
     bool m_bParsingStyle;
+    bool m_bConvertingContent;
 protected:
     virtual void Read();
     virtual void RegisterStyle();
     virtual void Parse(IXFStream* pOutputStream);
+    virtual void XFConvert(XFContentContainer* pCont);
 public:
     void QuickRead();
     //calls RegisterStyle but bails if DoRegisterStyle is called
@@ -118,8 +120,16 @@ public:
         Parse(pOutputStream);
         m_bParsingStyle = false;
     }
-
-    virtual void XFConvert(XFContentContainer* pCont);
+    //calls XFConvert but bails if DoXFConvert is called
+    //on the same object recursively
+    void DoXFConvert(XFContentContainer* pCont)
+    {
+        if (m_bConvertingContent)
+            throw std::runtime_error("recursion in parsing");
+        m_bConvertingContent = true;
+        XFConvert(pCont);
+        m_bConvertingContent = false;
+    }
 
     LwpFoundry* GetFoundry(){return m_pFoundry;}
     void SetFoundry(LwpFoundry* pFoundry){m_pFoundry = pFoundry;}
diff --git a/lotuswordpro/source/filter/lwppagelayout.cxx b/lotuswordpro/source/filter/lwppagelayout.cxx
index 3b10d2c..d57eadc 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -889,7 +889,7 @@ void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
         RegisterChildStyle();
         //End
         pChangeMgr->SetHeadFootChange(pHeader);
-        pStory->XFConvert(pHeader);
+        pStory->DoXFConvert(pHeader);
 
         pChangeMgr->SetHeadFootFribMap(false);
     }
@@ -1042,7 +1042,7 @@ void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
 
         pChangeMgr->SetHeadFootChange(pFooter);
 
-        pStory->XFConvert(pFooter);
+        pStory->DoXFConvert(pFooter);
 
         pChangeMgr->SetHeadFootFribMap(false);
     }
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index 6abdba4..09acda7 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -314,7 +314,7 @@ void LwpStory::XFConvertFrameInCell(XFContentContainer* pCont)
                     pCont->FindFirstContent(enumXFContentPara));
                 XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
                 if(pXFFirtPara)
-                    xFrameLayout->XFConvert(pXFFirtPara);
+                    xFrameLayout->DoXFConvert(pXFFirtPara);
             }
             xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
         }
@@ -338,7 +338,7 @@ void LwpStory::XFConvertFrameInPage(XFContentContainer* pCont)
                       || xFrameLayout->IsSuperTable()
                       || xFrameLayout->IsGroupHead())))
             {
-                xFrameLayout->XFConvert(pCont);
+                xFrameLayout->DoXFConvert(pCont);
             }
             xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
         }
@@ -358,7 +358,7 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont)
         {
             if (xFrameLayout->IsAnchorFrame())
             {
-                xFrameLayout->XFConvert(pCont);
+                xFrameLayout->DoXFConvert(pCont);
             }
             xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
         }
@@ -383,7 +383,7 @@ void LwpStory::XFConvertFrameInHeaderFooter(XFContentContainer* pCont)
                     pCont->FindFirstContent(enumXFContentPara));
                 XFContentContainer* pXFFirtPara = static_cast<XFContentContainer*>(first.get());
                 if(pXFFirtPara)
-                    xFrameLayout->XFConvert(pXFFirtPara);
+                    xFrameLayout->DoXFConvert(pXFFirtPara);
             }
             xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
         }


More information about the Libreoffice-commits mailing list