summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2013-05-13 17:37:50 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2013-05-16 11:19:32 +0200
commitcee96ac9c759f1168e7ca2e8df54994dc2f641d6 (patch)
tree0e37a614234adc6166ada64829f35de174f5f6d9
parentd75b15f6530374f9274ccb01fbc7d783a029f32e (diff)
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::string, std::pair<std::string const, std::string>, std::_Select1st<std::pair<std::string const, std::string> >, std::less<std::string>, std::allocator<std::pair<std::string const, std::string> > >::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
-rw-r--r--src/backends/webdav/WebDAVSource.cpp23
1 files 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::function<bool (const std::string
path = newpath;
}
}
- StringMap &props = pathProps->second;
+ 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::function<bool (const std::string
// found something
tried.foundResult();
- it = props.find("DAV::displayname");
+ it = props->find("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<bool (const std::string
// find next path:
// prefer CardDAV:calendar-home-set or CalDAV:addressbook-home-set
- std::list<std::string> homes = extractHREFs(props[homeSetProp()]);
+ std::list<std::string> 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<bool (const std::string
}
// alternatively, follow principal URL
if (next.empty()) {
- std::string principal = extractHREF(props["DAV::current-user-principal"]);
+ std::string principal;
+ if (props) {
+ principal = extractHREF((*props)["DAV::current-user-principal"]);
+ }
// TODO:
// xmlns:d="DAV:"
@@ -1032,7 +1038,10 @@ bool WebDAVSource::findCollections(const boost::function<bool (const std::string
// unless we identified it as a result (because those
// cannot be recursive)
if (next.empty() && !isResult) {
- const std::string &type = props["DAV::resourcetype"];
+ std::string type;
+ if (props) {
+ type = (*props)["DAV::resourcetype"];
+ }
if (type.find("<DAV:collection></DAV:collection>") != type.npos) {
// List members and find new candidates.
// Yahoo! Calendar does not return resources contained in /dav/<user>/Calendar/