[evolution-data-server] calendar file backend: white list check for supported CalObjModType



commit bbe2d0a49089ee9f5522ce2749a009c730dd9079
Author: Patrick Ohly <patrick ohly intel com>
Date:   Thu May 12 09:48:37 2011 +0200

    calendar file backend: white list check for supported CalObjModType
    
    Explicitly check that the CalObjModType is supported before
    starting to work on the appointment. Relies in libecal to reject
    completely bogus modes with an "invalid parameter" error.

 calendar/backends/file/e-cal-backend-file.c |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/calendar/backends/file/e-cal-backend-file.c b/calendar/backends/file/e-cal-backend-file.c
index eb22a4c..564304c 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -2196,6 +2196,16 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
 
 	e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
 	e_return_data_cal_error_if_fail (calobj != NULL, ObjectNotFound);
+	switch (mod) {
+	case CALOBJ_MOD_THIS:
+	case CALOBJ_MOD_THISANDPRIOR:
+	case CALOBJ_MOD_THISANDFUTURE:
+	case CALOBJ_MOD_ALL:
+		break;
+	default:
+		g_propagate_error (error, EDC_ERROR (NotSupported));
+		return;
+	}
 
 	/* Parse the icalendar text */
 	icalcomp = icalparser_parse_string ((gchar *) calobj);
@@ -2394,6 +2404,9 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, GCanc
 			g_list_free (detached);
 		}
 		break;
+	case CALOBJ_MOD_ONLY_THIS:
+		// not reached, keep compiler happy
+		break;
 	}
 
 	save (cbfile);
@@ -2538,6 +2551,16 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
 
 	e_return_data_cal_error_if_fail (priv->icalcomp != NULL, NoSuchCal);
 	e_return_data_cal_error_if_fail (uid != NULL, ObjectNotFound);
+	switch (mod) {
+	case CALOBJ_MOD_THIS:
+	case CALOBJ_MOD_THISANDPRIOR:
+	case CALOBJ_MOD_THISANDFUTURE:
+	case CALOBJ_MOD_ALL:
+		break;
+	default:
+		g_propagate_error (error, EDC_ERROR (NotSupported));
+		return;
+	}
 
 	*old_object = *object = NULL;
 
@@ -2560,6 +2583,9 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal, GCanc
 
 		*object = NULL;
 		break;
+	case CALOBJ_MOD_ONLY_THIS:
+		/* not reached, keep compiler happy */
+		break;
 	case CALOBJ_MOD_THIS :
 		*old_object = get_object_string_from_fileobject (obj_data, recur_id);
 



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