[evolution-data-server/gnome-3-32] [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/gnome-3-32] [EWebDAVDiscover] Prevent crash on GError use in gio functions
- Date: Mon, 29 Apr 2019 12:35:10 +0000 (UTC)
commit 6c2eaf9fa7a7a32b9a3e89f62850ea05876192f6
Author: Milan Crha <mcrha redhat com>
Date: Mon Apr 29 14:36:48 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 a8efac8b5..2aadd0144 100644
--- a/src/libedataserver/e-webdav-discover.c
+++ b/src/libedataserver/e-webdav-discover.c
@@ -118,18 +118,24 @@ 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,
- &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);
@@ -151,18 +157,24 @@ 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,
- &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);
@@ -236,17 +248,23 @@ e_webdav_discover_traverse_propfind_response_cb (EWebDAVSession *webdav,
if (e_xml_xpath_eval_exists (xpath_ctx, "%s/D:resourcetype/C:calendar", xpath_prop_prefix) ||
e_xml_xpath_eval_exists (xpath_ctx, "%s/D:resourcetype/A:addressbook",
xpath_prop_prefix)) {
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,
- &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);
}
}
@@ -261,6 +279,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);
@@ -296,10 +315,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]