[evolution/wip/gsettings] Bug #608804 - Some attachments make evolution crash in libical



commit 410dbf8e7ab784df090650104d3e2334487c110e
Author: Milan Crha <mcrha redhat com>
Date:   Tue Feb 22 13:54:34 2011 +0100

    Bug #608804 - Some attachments make evolution crash in libical

 modules/calendar/e-cal-attachment-handler.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)
---
diff --git a/modules/calendar/e-cal-attachment-handler.c b/modules/calendar/e-cal-attachment-handler.c
index 8fea91f..dfc8f58 100644
--- a/modules/calendar/e-cal-attachment-handler.c
+++ b/modules/calendar/e-cal-attachment-handler.c
@@ -83,7 +83,19 @@ attachment_handler_get_component (EAttachment *attachment)
 	camel_data_wrapper_decode_to_stream_sync (wrapper, stream, NULL, NULL);
 	g_object_unref (stream);
 
-	component = e_cal_util_parse_ics_string ((gchar *) buffer->data);
+	if (buffer->len > 0) {
+		const gchar *str;
+
+		/* ensure string being null-terminated  */
+		g_byte_array_append (buffer, (const guint8 *) "", 1);
+
+		str = (const gchar *) buffer->data;
+		while (*str && g_ascii_isspace (*str))
+			str++;
+
+		if (g_ascii_strncasecmp (str, "BEGIN:", 6) == 0)
+			component = e_cal_util_parse_ics_string (str);
+	}
 
 	g_byte_array_free (buffer, TRUE);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]