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

Caolán McNamara caolanm at redhat.com
Tue Mar 15 11:58: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 8978c75cb0fdb1a5cddbe25545f0455074afecf6
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Mar 15 09:21:10 2016 +0000

    recurse protection for XFConvert
    
    Change-Id: Ib6008d4b07159acad26c7baeb775702119c12e3b
    (cherry picked from commit 9e0004f2cc64ffa23ecd5c7c82016624eb8a5a20)
    Reviewed-on: https://gerrit.libreoffice.org/23259
    Reviewed-by: David Tardon <dtardon at redhat.com>
    Tested-by: David Tardon <dtardon at redhat.com>

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 0964eda..8c53f39 100644
--- a/lotuswordpro/source/filter/lwpfootnote.cxx
+++ b/lotuswordpro/source/filter/lwpfootnote.cxx
@@ -194,7 +194,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 5599e85..b9b5712 100644
--- a/lotuswordpro/source/filter/lwpframelayout.cxx
+++ b/lotuswordpro/source/filter/lwpframelayout.cxx
@@ -840,7 +840,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);
             }
@@ -1108,7 +1108,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 6b1d5f8..2d7e91c 100644
--- a/lotuswordpro/source/filter/lwpfribframe.cxx
+++ b/lotuswordpro/source/filter/lwpfribframe.cxx
@@ -186,7 +186,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 bd16ae9..d85b545 100644
--- a/lotuswordpro/source/filter/lwpnotes.cxx
+++ b/lotuswordpro/source/filter/lwpnotes.cxx
@@ -184,7 +184,7 @@ void LwpNoteLayout::XFConvert(XFContentContainer * pCont)
     LwpVirtualLayout* pTextLayout = GetTextLayout();
     if(pTextLayout)
     {
-        pTextLayout->XFConvert(pCont);
+        pTextLayout->DoXFConvert(pCont);
     }
 }
 
@@ -293,7 +293,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 be9a07f..919e392 100644
--- a/lotuswordpro/source/filter/lwpobj.cxx
+++ b/lotuswordpro/source/filter/lwpobj.cxx
@@ -66,6 +66,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 978bc49..4b2e7b1 100644
--- a/lotuswordpro/source/filter/lwpobj.hxx
+++ b/lotuswordpro/source/filter/lwpobj.hxx
@@ -96,10 +96,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
@@ -122,8 +124,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 776b574..915e1c8 100644
--- a/lotuswordpro/source/filter/lwppagelayout.cxx
+++ b/lotuswordpro/source/filter/lwppagelayout.cxx
@@ -892,7 +892,7 @@ void LwpHeaderLayout::RegisterStyle(XFMasterPage* mp1)
         RegisterChildStyle();
         //End
         pChangeMgr->SetHeadFootChange(pHeader);
-        pStory->XFConvert(pHeader);
+        pStory->DoXFConvert(pHeader);
 
         pChangeMgr->SetHeadFootFribMap(false);
     }
@@ -1046,7 +1046,7 @@ void LwpFooterLayout::RegisterStyle(XFMasterPage* mp1)
 
         pChangeMgr->SetHeadFootChange(pFooter);//add by ,7/6
 
-        pStory->XFConvert(pFooter);
+        pStory->DoXFConvert(pFooter);
 
         pChangeMgr->SetHeadFootFribMap(false);
     }
diff --git a/lotuswordpro/source/filter/lwpstory.cxx b/lotuswordpro/source/filter/lwpstory.cxx
index 64c2555..1722127 100644
--- a/lotuswordpro/source/filter/lwpstory.cxx
+++ b/lotuswordpro/source/filter/lwpstory.cxx
@@ -334,7 +334,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()));
         }
@@ -361,7 +361,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()));
         }
@@ -384,7 +384,7 @@ void LwpStory::XFConvertFrameInFrame(XFContentContainer* pCont)
         {
             if (xFrameLayout->IsAnchorFrame())
             {
-                xFrameLayout->XFConvert(pCont);
+                xFrameLayout->DoXFConvert(pCont);
             }
             xFrameLayout.set(dynamic_cast<LwpVirtualLayout*>(xFrameLayout->GetNext().obj().get()));
         }
@@ -412,7 +412,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