[evolution-data-server/pohly-gnome-2-32: 6/10] calendar file backend: white list check for supported CalObjModType



commit 1da8ab59739911ef7704b2bec1e4a3985977e36d
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 7a8c450..c0059d6 100644
--- a/calendar/backends/file/e-cal-backend-file.c
+++ b/calendar/backends/file/e-cal-backend-file.c
@@ -2420,6 +2420,16 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
 
 	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);
@@ -2618,6 +2628,9 @@ e_cal_backend_file_modify_object (ECalBackendSync *backend, EDataCal *cal, const
 			g_list_free (detached);
 		}
 		break;
+	case CALOBJ_MOD_ONLY_THIS:
+		// not reached, keep compiler happy
+		break;
 	}
 
 	save (cbfile);
@@ -2762,6 +2775,16 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
 
 	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;
 
@@ -2784,6 +2807,9 @@ e_cal_backend_file_remove_object (ECalBackendSync *backend, EDataCal *cal,
 
 		*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]