[evolution-ews/evolution-ews-3-12] Bug 692780 - Crash under ews_get_attachments()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-ews/evolution-ews-3-12] Bug 692780 - Crash under ews_get_attachments()
- Date: Wed, 28 May 2014 11:26:22 +0000 (UTC)
commit 5a6baec32fa8d6a7506db2ed9dc265928b100874
Author: Milan Crha <mcrha redhat com>
Date: Wed May 28 13:22:39 2014 +0200
Bug 692780 - Crash under ews_get_attachments()
Maybe not a real fix for this, but I cannot reproduce it, thus I added
a bit more thread-safety to the code and an ensure to not access
uninitialized memory in the future.
src/calendar/e-cal-backend-ews-utils.c | 31 --------------------
src/calendar/e-cal-backend-ews-utils.h | 3 --
src/calendar/e-cal-backend-ews.c | 48 ++++++++++++++++++++-----------
3 files changed, 31 insertions(+), 51 deletions(-)
---
diff --git a/src/calendar/e-cal-backend-ews-utils.c b/src/calendar/e-cal-backend-ews-utils.c
index efa0701..f7e247d 100644
--- a/src/calendar/e-cal-backend-ews-utils.c
+++ b/src/calendar/e-cal-backend-ews-utils.c
@@ -210,37 +210,6 @@ e_cal_backend_ews_tz_util_get_ical_equivalent (const gchar *msdn_tz_location)
return ical_tz_location;
}
-EwsCalendarConvertData *
-ews_calendar_convert_data_new (void)
-{
- return g_new0 (EwsCalendarConvertData, 1);
-}
-
-void
-ews_calendar_convert_data_free (EwsCalendarConvertData *convert_data)
-{
- if (convert_data != NULL) {
- if (convert_data->connection != NULL)
- g_clear_object (&convert_data->connection);
- if (convert_data->comp != NULL)
- g_clear_object (&convert_data->comp);
- if (convert_data->old_comp != NULL)
- g_clear_object (&convert_data->old_comp);
- if (convert_data->default_zone != NULL)
- icaltimezone_free (convert_data->default_zone, TRUE);
- if (convert_data->icalcomp != NULL)
- icalcomponent_free (convert_data->icalcomp);
-
- g_free (convert_data->item_id);
- g_free (convert_data->change_key);
- g_free (convert_data->user_email);
- g_free (convert_data->response_type);
- g_slist_free_full (convert_data->users, g_free);
-
- g_free (convert_data);
- }
-}
-
/*
* Iterate over the icalcomponent properties and collect attendees
*/
diff --git a/src/calendar/e-cal-backend-ews-utils.h b/src/calendar/e-cal-backend-ews-utils.h
index 3b02228..c17c803 100644
--- a/src/calendar/e-cal-backend-ews-utils.h
+++ b/src/calendar/e-cal-backend-ews-utils.h
@@ -54,9 +54,6 @@ typedef struct {
time_t end;
} EwsCalendarConvertData;
-EwsCalendarConvertData *ews_calendar_convert_data_new (void);
-void ews_calendar_convert_data_free (EwsCalendarConvertData *convert_data);
-
const gchar *e_ews_collect_organizer (icalcomponent *comp);
void e_ews_collect_attendees (icalcomponent *comp, GSList **required, GSList **optional, GSList **resource);
diff --git a/src/calendar/e-cal-backend-ews.c b/src/calendar/e-cal-backend-ews.c
index 04fcfdf..55b61df 100644
--- a/src/calendar/e-cal-backend-ews.c
+++ b/src/calendar/e-cal-backend-ews.c
@@ -377,7 +377,7 @@ e_cal_backend_ews_discard_alarm (ECalBackend *backend,
ECalBackendEws *cbews = (ECalBackendEws *) backend;
ECalBackendEwsPrivate *priv;
EwsCalendarAsyncData *edad;
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
ECalComponent *comp;
GError *local_error = NULL;
@@ -1342,7 +1342,7 @@ ews_create_attachments_cb (GObject *object,
const gchar *send_meeting_invitations;
const gchar *send_or_save;
EwsCalendarAsyncData *modify_data;
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
modify_data = g_new0 (EwsCalendarAsyncData, 1);
modify_data->cbews = g_object_ref (create_data->cbews);
@@ -1626,7 +1626,7 @@ e_cal_backend_ews_create_objects (ECalBackend *backend,
const GSList *calobjs)
{
EwsCalendarAsyncData *create_data;
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
EwsFolderId *fid;
ECalBackendEws *cbews;
ECalBackendEwsPrivate *priv;
@@ -1868,7 +1868,7 @@ e_cal_backend_ews_modify_object (ECalBackend *backend,
ECalBackendEws *cbews;
ECalBackendEwsPrivate *priv;
icalcomponent_kind kind;
- ECalComponent *comp = NULL, *oldcomp;
+ ECalComponent *comp = NULL, *oldcomp = NULL;
icalcomponent *icalcomp;
gchar *itemid = NULL, *changekey = NULL;
struct icaltimetype current;
@@ -1925,6 +1925,7 @@ e_cal_backend_ews_modify_object (ECalBackend *backend,
PRIV_UNLOCK (priv);
goto exit;
}
+ g_object_ref (oldcomp);
PRIV_UNLOCK (priv);
e_cal_backend_ews_pick_all_tzids_out (cbews, e_cal_component_get_icalcomponent (oldcomp));
@@ -2036,7 +2037,7 @@ e_cal_backend_ews_modify_object (ECalBackend *backend,
g_free (item_id);
} else {
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
const gchar *send_meeting_invitations;
const gchar *send_or_save;
@@ -2077,11 +2078,14 @@ e_cal_backend_ews_modify_object (ECalBackend *backend,
ews_cal_modify_object_cb,
modify_data);
}
+
+ g_clear_object (&oldcomp);
+
return;
exit:
- if (comp != NULL)
- g_object_unref (comp);
+ g_clear_object (&oldcomp);
+ g_clear_object (&comp);
convert_error_to_edc_error (&error);
if (context)
@@ -2099,7 +2103,7 @@ e_ews_receive_objects_no_exchange_mail (ECalBackendEws *cbews,
GCancellable *cancellable,
GError **error)
{
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
EwsFolderId *fid;
convert_data.connection = cbews->priv->cnc;
@@ -2180,7 +2184,7 @@ ews_cal_do_method_request_publish_reply (ECalBackendEws *cbews,
if (item_id == NULL) {
e_ews_receive_objects_no_exchange_mail (cbews, subcomp, &ids, cancellable,
&local_error);
} else {
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
convert_data.response_type = (gchar *) response_type;
convert_data.item_id = item_id;
@@ -2266,7 +2270,7 @@ ews_cal_do_method_request_publish_reply (ECalBackendEws *cbews,
if (g_strcmp0 (icalproperty_get_value_as_string (transp), "TRANSPARENT") == 0 &&
g_strcmp0 (response_type, "ACCEPTED") == 0) {
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
GSList *l;
/*
@@ -2723,13 +2727,17 @@ ews_get_attachments (ECalBackendEws *cbews,
}
id = e_cal_component_get_id (comp);
- cache_comp = e_cal_backend_store_get_component (cbews->priv->store, id->uid, id->rid);
- e_cal_component_free_id (id);
+ if (!id) {
+ g_warn_if_reached ();
+ } else {
+ cache_comp = e_cal_backend_store_get_component (cbews->priv->store, id->uid, id->rid);
+ e_cal_component_free_id (id);
- put_component_to_store (cbews, comp);
+ put_component_to_store (cbews, comp);
- if (cache_comp)
- e_cal_backend_notify_component_modified (E_CAL_BACKEND (cbews), cache_comp, comp);
+ if (cache_comp)
+ e_cal_backend_notify_component_modified (E_CAL_BACKEND (cbews), cache_comp,
comp);
+ }
g_slist_free_full (uris, g_free);
g_slist_free_full (info_attachments, (GDestroyNotify) e_ews_attachment_info_free);
@@ -3398,11 +3406,17 @@ cal_backend_ews_process_folder_items (ECalBackendEws *cbews,
PRIV_LOCK (priv);
comp = g_hash_table_lookup (priv->item_id_hash, item_id);
+ if (comp)
+ g_object_ref (comp);
PRIV_UNLOCK (priv);
if (comp) {
- if (!ews_cal_delete_comp (cbews, comp, item_id))
+ if (!ews_cal_delete_comp (cbews, comp, item_id)) {
+ g_object_unref (comp);
goto exit;
+ }
+
+ g_object_unref (comp);
}
}
e_cal_backend_store_thaw_changes (priv->store);
@@ -3778,7 +3792,7 @@ e_cal_backend_ews_get_free_busy (ECalBackend *backend,
ECalBackendEwsPrivate *priv = cbews->priv;
GError *error = NULL;
EwsCalendarAsyncData *free_busy_data;
- EwsCalendarConvertData convert_data;
+ EwsCalendarConvertData convert_data = { 0 };
GSList *users_copy = NULL;
/* make sure we're not offline */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]