[evolution-data-server] [EWebDAVDiscover] Prevent crash on GError use in gio functions
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] [EWebDAVDiscover] Prevent crash on GError use in gio functions
- Date: Mon, 29 Apr 2019 12:29:52 +0000 (UTC)
commit cd643b8d7c0934d80bb5a715e36f2aa2966da7d6
Author: Milan Crha <mcrha redhat com>
Date: Mon Apr 29 14:29:25 2019 +0200
[EWebDAVDiscover] Prevent crash on GError use in gio functions
When the server returns invalid address and the call fails then
the wdd->error could be set. Retrying another href with this set
error can be caught by gio's assertions like this:
GLib-Net:ERROR:../tls/gnutls/gtlsconnection-gnutls.c:910:end_gnutls_io: assertion failed: (!error ||
!*error)
src/libedataserver/e-webdav-discover.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/libedataserver/e-webdav-discover.c b/src/libedataserver/e-webdav-discover.c
index c7944bb10..16ac99ca6 100644
--- a/src/libedataserver/e-webdav-discover.c
+++ b/src/libedataserver/e-webdav-discover.c
@@ -119,19 +119,25 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
home_set_href = e_xml_xpath_eval_as_string (xpath_ctx,
"%s/A:addressbook-home-set/D:href[%d]", xpath_prop_prefix, ii + 1);
if (home_set_href && *home_set_href) {
GSList *resources = NULL;
+ GError *local_error = NULL;
full_href = e_webdav_session_ensure_full_uri (webdav, request_uri,
home_set_href);
if (full_href && *full_href && !g_hash_table_contains
(wdd->covered_hrefs, full_href) &&
e_webdav_session_list_sync (webdav, full_href,
E_WEBDAV_DEPTH_THIS_AND_CHILDREN,
E_WEBDAV_LIST_SUPPORTS | E_WEBDAV_LIST_DISPLAY_NAME |
E_WEBDAV_LIST_DESCRIPTION |
E_WEBDAV_LIST_COLOR | E_WEBDAV_LIST_ONLY_ADDRESSBOOK,
- &resources, wdd->cancellable, wdd->error)) {
+ &resources, wdd->cancellable, &local_error)) {
e_webdav_discover_split_resources (wdd, resources);
g_slist_free_full (resources, e_webdav_resource_free);
}
if (full_href && *full_href)
g_hash_table_insert (wdd->covered_hrefs, g_strdup
(full_href), GINT_TO_POINTER (1));
+
+ if (local_error && wdd->error && !*wdd->error)
+ g_propagate_error (wdd->error, local_error);
+ else
+ g_clear_error (&local_error);
}
g_free (home_set_href);
@@ -153,19 +159,25 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
home_set_href = e_xml_xpath_eval_as_string (xpath_ctx,
"%s/C:calendar-home-set/D:href[%d]", xpath_prop_prefix, ii + 1);
if (home_set_href && *home_set_href) {
GSList *resources = NULL;
+ GError *local_error = NULL;
full_href = e_webdav_session_ensure_full_uri (webdav, request_uri,
home_set_href);
if (full_href && *full_href && !g_hash_table_contains
(wdd->covered_hrefs, full_href) &&
e_webdav_session_list_sync (webdav, full_href,
E_WEBDAV_DEPTH_THIS_AND_CHILDREN,
E_WEBDAV_LIST_SUPPORTS | E_WEBDAV_LIST_DISPLAY_NAME |
E_WEBDAV_LIST_DESCRIPTION |
E_WEBDAV_LIST_COLOR | E_WEBDAV_LIST_ONLY_CALENDAR,
- &resources, wdd->cancellable, wdd->error)) {
+ &resources, wdd->cancellable, &local_error)) {
e_webdav_discover_split_resources (wdd, resources);
g_slist_free_full (resources, e_webdav_resource_free);
}
if (full_href && *full_href)
g_hash_table_insert (wdd->covered_hrefs, g_strdup
(full_href), GINT_TO_POINTER (1));
+
+ if (local_error && wdd->error && !*wdd->error)
+ g_propagate_error (wdd->error, local_error);
+ else
+ g_clear_error (&local_error);
}
g_free (home_set_href);
@@ -241,18 +253,24 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
if (is_calendar || is_addressbook) {
GSList *resources = NULL;
+ GError *local_error = NULL;
if (!g_hash_table_contains (wdd->covered_hrefs, href) &&
!g_cancellable_is_cancelled (wdd->cancellable) &&
e_webdav_session_list_sync (webdav, href, E_WEBDAV_DEPTH_THIS,
E_WEBDAV_LIST_SUPPORTS | E_WEBDAV_LIST_DISPLAY_NAME |
E_WEBDAV_LIST_DESCRIPTION | E_WEBDAV_LIST_COLOR |
(is_calendar ? E_WEBDAV_LIST_ONLY_CALENDAR : 0) | (is_addressbook ?
E_WEBDAV_LIST_ONLY_ADDRESSBOOK : 0),
- &resources, wdd->cancellable, wdd->error)) {
+ &resources, wdd->cancellable, &local_error)) {
e_webdav_discover_split_resources (wdd, resources);
g_slist_free_full (resources, e_webdav_resource_free);
}
g_hash_table_insert (wdd->covered_hrefs, g_strdup (href), GINT_TO_POINTER (1));
+
+ if (local_error && wdd->error && !*wdd->error)
+ g_propagate_error (wdd->error, local_error);
+ else
+ g_clear_error (&local_error);
}
}
@@ -267,6 +285,7 @@ e_webdav_discover_propfind_uri_sync (EWebDAVSession *webdav,
{
EXmlDocument *xml;
gboolean success;
+ GError *local_error = NULL;
g_return_val_if_fail (E_IS_WEBDAV_SESSION (webdav), FALSE);
g_return_val_if_fail (wdd != NULL, FALSE);
@@ -302,10 +321,15 @@ e_webdav_discover_propfind_uri_sync (EWebDAVSession *webdav,
e_xml_document_end_element (xml); /* prop */
success = e_webdav_session_propfind_sync (webdav, uri, E_WEBDAV_DEPTH_THIS, xml,
- e_webdav_discover_traverse_propfind_response_cb, wdd, wdd->cancellable, wdd->error);
+ e_webdav_discover_traverse_propfind_response_cb, wdd, wdd->cancellable, &local_error);
g_clear_object (&xml);
+ if (local_error && wdd->error && !*wdd->error)
+ g_propagate_error (wdd->error, local_error);
+ else
+ g_clear_error (&local_error);
+
return success;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]