[evolution-exchange/gnome-2-32] Bug #634573 - Crash when importing ics file
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-exchange/gnome-2-32] Bug #634573 - Crash when importing ics file
- Date: Fri, 19 Nov 2010 14:48:35 +0000 (UTC)
commit 9ad860d50e3b989835f8ae9a586a20f35d98ca45
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 19 15:48:16 2010 +0100
Bug #634573 - Crash when importing ics file
calendar/e-cal-backend-exchange-calendar.c | 4 +-
calendar/e-cal-backend-exchange.c | 29 ++++++++++++++++++++++++---
2 files changed, 27 insertions(+), 6 deletions(-)
---
diff --git a/calendar/e-cal-backend-exchange-calendar.c b/calendar/e-cal-backend-exchange-calendar.c
index 7149042..a63e9dd 100644
--- a/calendar/e-cal-backend-exchange-calendar.c
+++ b/calendar/e-cal-backend-exchange-calendar.c
@@ -1720,7 +1720,7 @@ receive_objects (ECalBackendSync *backend, EDataCal *cal,
if (e_cal_util_component_is_instance (subcomp))
mod = CALOBJ_MOD_THIS;
- icalobj = (gchar *) icalcomponent_as_ical_string_r (subcomp);
+ icalobj = e_cal_component_get_as_string (comp);
if (!modify_object_with_href (backend, cal, icalobj,
mod,
&old_object, &new_object, NULL, NULL, error)) {
@@ -1747,7 +1747,7 @@ receive_objects (ECalBackendSync *backend, EDataCal *cal,
}
d(printf ("object : %s .. not found in the cache\n", uid));
- icalobj = (gchar *) icalcomponent_as_ical_string_r (subcomp);
+ icalobj = e_cal_component_get_as_string (comp);
d(printf ("Create a new object : %s\n", icalobj));
e_cal_backend_exchange_cache_unlock (cbex);
diff --git a/calendar/e-cal-backend-exchange.c b/calendar/e-cal-backend-exchange.c
index f5facc0..6c2bae1 100644
--- a/calendar/e-cal-backend-exchange.c
+++ b/calendar/e-cal-backend-exchange.c
@@ -1742,6 +1742,16 @@ save_attach_file (const gchar *dest_file, gchar *file_contents, gint len)
/* Write it to our local exchange store. */
fd = g_open (dest_file, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
if (fd < 0) {
+ gchar *dir = g_path_get_dirname (dest_file);
+
+ if (dir && (dir[0] != '.' || !dir[1]) &&
+ g_mkdir_with_parents (dir, 0700) >= 0)
+ fd = g_open (dest_file, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0600);
+
+ g_free (dir);
+ }
+
+ if (fd < 0) {
d(printf ("open of destination file for attachments failed\n"));
goto end;
}
@@ -1955,12 +1965,22 @@ receive_attachments (ECalBackendExchange *cbex, ECalComponent *comp)
e_cal_component_get_attachment_list (comp, &attach_list);
for (l = attach_list; l; l = l->next) {
- gchar *fname, *dest_url, *attach_file = NULL, *file_contents;
+ const gchar *fname;
+ gchar *dest_url, *attach_file = NULL, *file_contents, *old_file = NULL;
gint len = 0;
if (!strncmp ((gchar *)l->data, "file://", 7)) {
- fname = g_filename_from_uri ((gchar *)l->data, NULL, NULL);
- attach_file = fname;
+ attach_file = g_filename_from_uri ((gchar *)l->data, NULL, NULL);
+ fname = attach_file;
+
+ if (fname && cbex->priv->local_attachment_store && !g_str_has_prefix (fname, cbex->priv->local_attachment_store)) {
+ /* it's not in our store, thus save it there */
+ gchar *base_name = g_path_get_basename (attach_file);
+
+ old_file = attach_file;
+ attach_file = g_build_filename (cbex->priv->local_attachment_store, uid, base_name, NULL);
+ g_free (base_name);
+ }
} else {
const gchar *filename;
@@ -1978,6 +1998,7 @@ receive_attachments (ECalBackendExchange *cbex, ECalComponent *comp)
/* attach_file should be g_freed */
file_contents = get_attach_file_contents (fname, &len);
+ g_free (old_file);
if (!file_contents) {
g_free (attach_file);
continue;
@@ -2119,8 +2140,8 @@ build_msg ( ECalBackendExchange *cbex, ECalComponent *comp, const gchar *subject
stream = camel_stream_mem_new_with_byte_array (byte_array);
dw = camel_medium_get_content (CAMEL_MEDIUM (msg));
camel_data_wrapper_decode_to_stream (dw, stream, NULL);
+ g_byte_array_append (byte_array, (guint8 *) "", 1);
buffer = g_memdup (byte_array->data, byte_array->len);
- buffer[byte_array->len] = '\0';
d(printf ("|| Buffer: \n%s\n", buffer));
g_object_unref (stream);
g_object_unref (msg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]