From cee96ac9c759f1168e7ca2e8df54994dc2f641d6 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 13 May 2013 17:37:50 +0200 Subject: WebDAV: avoid segfault during collection lookup Avoid referencing pathProps->second when the set of paths that PROPFINDs returns is empty. Apparently this can happen in combination with Calypso. The stack backtrace sent via email looked like this: Program received signal SIGSEGV, Segmentation fault. 0x4031a1a0 in std::_Rb_tree, std::_Select1st >, std::less, std::allocator > >::find(std::string const&) const () from /usr/lib/libsyncevolution.so.0 0x4031a1a0 <_ZNKSt8_Rb_treeISsSt4pairIKSsSsESt10_Select1stIS2_ESt4lessISsESaIS2_EE4findERS1_+60>: ldr r4, [r0, #-12] (gdb) bt from /usr/lib/syncevolution/backends/syncdav.so from /usr/lib/syncevolution/backends/syncdav.so from /usr/lib/libsyncevolution.so.0 --- src/backends/webdav/WebDAVSource.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/backends/webdav/WebDAVSource.cpp b/src/backends/webdav/WebDAVSource.cpp index 9d09e579..5d20d54a 100644 --- a/src/backends/webdav/WebDAVSource.cpp +++ b/src/backends/webdav/WebDAVSource.cpp @@ -970,9 +970,9 @@ bool WebDAVSource::findCollections(const boost::functionsecond; + StringMap *props = pathProps == m_davProps.end() ? NULL : &pathProps->second; bool isResult = false; - if (typeMatches(props)) { + if (props && typeMatches(*props)) { isResult = true; StringMap::const_iterator it; @@ -982,11 +982,11 @@ bool WebDAVSource::findCollections(const boost::functionfind("DAV::displayname"); Neon::URI uri = m_session->getURI(); uri.m_path = path; std::string name; - if (it != props.end()) { + if (it != props->end()) { name = it->second; } SE_LOG_DEBUG(NULL, "found %s = %s", @@ -1002,7 +1002,10 @@ bool WebDAVSource::findCollections(const boost::function homes = extractHREFs(props[homeSetProp()]); + std::list homes; + if (props) { + homes = extractHREFs((*props)[homeSetProp()]); + } BOOST_FOREACH(const std::string &home, homes) { if (!home.empty() && tried.isNew(home)) { @@ -1017,7 +1020,10 @@ bool WebDAVSource::findCollections(const boost::function") != type.npos) { // List members and find new candidates. // Yahoo! Calendar does not return resources contained in /dav//Calendar/ -- cgit v1.2.3