aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2009-04-27 18:17:51 +0800
committerMilan Crha <mcrha@redhat.com>2009-04-27 18:17:51 +0800
commit796768f54ef825baa310aacb0244bf3d904bc118 (patch)
tree4a6fe2a026a0d31c1fe5e92b6e0b33b51a52415b
parent960d91e3089d6e9c21d6065fca6729239c8f39d1 (diff)
downloadgsoc2013-evolution-796768f54ef825baa310aacb0244bf3d904bc118.tar.gz
gsoc2013-evolution-796768f54ef825baa310aacb0244bf3d904bc118.tar.zst
gsoc2013-evolution-796768f54ef825baa310aacb0244bf3d904bc118.zip
Sanitize values from GConf before using them
** Fix for bug #491755 * gui/alarm-notify/config-data.c: (config_data_set_last_notification_time), (config_data_get_last_notification_time): Sanitize values from GConf before using them.
-rw-r--r--calendar/ChangeLog9
-rw-r--r--calendar/gui/alarm-notify/config-data.c14
2 files changed, 19 insertions, 4 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index e5d81cf955..37a5e04fcf 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,12 @@
+2009-04-27 Milan Crha <mcrha@redhat.com>
+
+ ** Fix for bug #491755
+
+ * gui/alarm-notify/config-data.c:
+ (config_data_set_last_notification_time),
+ (config_data_get_last_notification_time):
+ Sanitize values from GConf before using them.
+
2009-04-24 Milan Crha <mcrha@redhat.com>
** Fix for bug #573704
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
index 81cbc3480c..5a05cfd341 100644
--- a/calendar/gui/alarm-notify/config-data.c
+++ b/calendar/gui/alarm-notify/config-data.c
@@ -259,7 +259,7 @@ void
config_data_set_last_notification_time (time_t t)
{
GConfClient *client;
- time_t current_t;
+ time_t current_t, now = time (NULL);
g_return_if_fail (t != -1);
@@ -269,7 +269,7 @@ config_data_set_last_notification_time (time_t t)
/* we only store the new notification time if it is bigger
than the already stored one */
current_t = gconf_client_get_int (client, KEY_LAST_NOTIFICATION_TIME, NULL);
- if (t > current_t)
+ if (t > current_t || current_t > now)
gconf_client_set_int (client, KEY_LAST_NOTIFICATION_TIME, t, NULL);
}
@@ -290,8 +290,14 @@ config_data_get_last_notification_time (void)
return -1;
value = gconf_client_get_without_default (client, KEY_LAST_NOTIFICATION_TIME, NULL);
- if (value)
- return (time_t) gconf_value_get_int (value);
+ if (value) {
+ time_t val = (time_t) gconf_value_get_int (value), now = time (NULL);
+
+ if (val > now)
+ val = now;
+
+ return val;
+ }
return time (NULL);
}