summaryrefslogtreecommitdiff
path: root/ucb
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2016-07-06 19:45:41 +1000
committerAndras Timar <andras.timar@collabora.com>2016-07-07 19:49:35 +0000
commitd1a32a01be704cf91ec1c2b779f21784e8c443a7 (patch)
treecd34d8e52599bce0e874034a43deac19632c443d /ucb
parenta38901295082ff72948a18fe9c82c37973061490 (diff)
tdf#100783 Avoid infinite recursion in Content::getObject()
With certain CMIS host URLs, it is possible that exception handler in Content::getObject() will recursively call itself with the same data (xParent from the same URL). This patch checks if the new URL is not the same as own, to avoid this. Change-Id: Ifaeb4ff27a9c809c5c96fa35ec190c3263a8fe62 Reviewed-on: https://gerrit.libreoffice.org/26977 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'ucb')
-rw-r--r--ucb/source/ucp/cmis/cmis_content.cxx21
1 files changed, 12 insertions, 9 deletions
diff --git a/ucb/source/ucp/cmis/cmis_content.cxx b/ucb/source/ucp/cmis/cmis_content.cxx
index c8958d8c437f..6180c6d7d30e 100644
--- a/ucb/source/ucp/cmis/cmis_content.cxx
+++ b/ucb/source/ucp/cmis/cmis_content.cxx
@@ -538,17 +538,20 @@ namespace cmis
string sName = OUSTR_TO_STDSTR( aParentUrl.getName( INetURLObject::LAST_SEGMENT, true, INetURLObject::DECODE_WITH_CHARSET ) );
aParentUrl.removeSegment( );
OUString sParentUrl = aParentUrl.GetMainURL( INetURLObject::NO_DECODE );
-
- rtl::Reference<Content> xParent( new Content(m_xContext, m_pProvider, new ucbhelper::ContentIdentifier( sParentUrl )) );
- libcmis::FolderPtr pParentFolder = boost::dynamic_pointer_cast< libcmis::Folder >( xParent->getObject( xEnv ) );
- if ( pParentFolder )
+ // Avoid infinite recursion if sParentUrl == m_sURL
+ if (sParentUrl != m_sURL)
{
- vector< libcmis::ObjectPtr > children = pParentFolder->getChildren( );
- for ( vector< libcmis::ObjectPtr >::iterator it = children.begin( );
- it != children.end() && !m_pObject; ++it )
+ rtl::Reference<Content> xParent(new Content(m_xContext, m_pProvider, new ucbhelper::ContentIdentifier(sParentUrl)));
+ libcmis::FolderPtr pParentFolder = boost::dynamic_pointer_cast< libcmis::Folder >(xParent->getObject(xEnv));
+ if (pParentFolder)
{
- if ( ( *it )->getName( ) == sName )
- m_pObject = *it;
+ vector< libcmis::ObjectPtr > children = pParentFolder->getChildren();
+ for (vector< libcmis::ObjectPtr >::iterator it = children.begin();
+ it != children.end() && !m_pObject; ++it)
+ {
+ if ((*it)->getName() == sName)
+ m_pObject = *it;
+ }
}
}