From d1a32a01be704cf91ec1c2b779f21784e8c443a7 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Wed, 6 Jul 2016 19:45:41 +1000 Subject: [PATCH] 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 Tested-by: Andras Timar --- ucb/source/ucp/cmis/cmis_content.cxx | 21 ++++++++++++--------- 1 file 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 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 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; + } } }