summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2016-03-15 09:21:10 +0000
committerAndras Timar <andras.timar@collabora.com>2016-03-17 14:35:48 +0100
commit61b4a873d94faa6fb4aac475b97b8d5cb0689937 (patch)
tree91acf258cc3557e4f49fe818ed6b3c2300219502
parenta70c989c91979d1ec4dd3403610e3ff9f071b0c5 (diff)
recurse protection for XFConvert
Change-Id: Ib6008d4b07159acad26c7baeb775702119c12e3b (cherry picked from commit 9e0004f2cc64ffa23ecd5c7c82016624eb8a5a20) Reviewed-on: https://gerrit.libreoffice.org/23259 Reviewed-by: David Tardon <dtardon@redhat.com> Tested-by: David Tardon <dtardon@redhat.com> (cherry picked from commit 8978c75cb0fdb1a5cddbe25545f0455074afecf6)
-rw-r--r--lotuswordpro/qa/cppunit/data/fail/recurse-2.lwpbin0 -> 15952 bytes
-rw-r--r--lotuswordpro/source/filter/lwpfootnote.cxx2
-rw-r--r--lotuswordpro/source/filter/lwpframelayout.cxx4
-rw-r--r--lotuswordpro/source/filter/lwpfribframe.cxx2
-rw-r--r--lotuswordpro/source/filter/lwpnotes.cxx4
-rw-r--r--lotuswordpro/source/filter/lwpobj.cxx1
-rw-r--r--lotuswordpro/source/filter/lwpobj.hxx14
-rw-r--r--lotuswordpro/source/filter/lwppagelayout.cxx4
-rw-r--r--lotuswordpro/source/filter/lwpstory.cxx8
9 files changed, 25 insertions, 14 deletions
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 000000000000..f19b0d7f7de3
--- /dev/null
+++ b/lotuswordpro/qa/cppunit/data/fail/recurse-2.lwp
Binary files differ
diff --git a/lotuswordpro/source/filter/lwpfootnote.cxx b/lotuswordpro/source/filter/lwpfootnote.cxx
index 0964edae2154..8c53f395af2c 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 19944f74f76c..28dc34e2dcb5 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);
}
@@ -1107,7 +1107,7 @@ void LwpGroupLayout::XFConvertFrame(XFContentContainer* pCont, sal_Int32 nStart
LwpVirtualLayout* pLayout = dynamic_cast<LwpVirtualLayout*>(GetChildHead().obj().get());
while(pLayout)
{
- 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 6b1d5f87948b..2d7e91c95f4c 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 bd16ae9708d1..d85b5451b841 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 be9a07f37c8e..919e392e6e10 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 978bc494a1b5..4b2e7b187870 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 a62d75057e41..9560b24d4cb4 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 64c255559d50..1722127c4390 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()));
}