From 7bebca1f2e4df2311742abc6538787598769f417 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 13 Dec 2007 14:44:37 +0000 Subject: [PATCH] Don't try to parse dates that start with anything but a digit, a plus or a 2007-12-13 Bastien Nocera * glib/gtimer.c: (g_time_val_from_iso8601): Don't try to parse dates that start with anything but a digit, a plus or a minus sign, as those can't be valid ISO8601 dates (Closes: #503029) svn path=/trunk/; revision=6111 --- ChangeLog | 7 +++++++ glib/gtimer.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6ded026ae..7e759569c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-12-13 Bastien Nocera + + * glib/gtimer.c: (g_time_val_from_iso8601): + Don't try to parse dates that start with anything but a + digit, a plus or a minus sign, as those can't be valid + ISO8601 dates (Closes: #503029) + 2007-12-13 Matthias Clasen * glib/gkeyfile.c (g_key_file_clear): Free group_hash. diff --git a/glib/gtimer.c b/glib/gtimer.c index aa290d05c..3b0b308c9 100644 --- a/glib/gtimer.c +++ b/glib/gtimer.c @@ -307,6 +307,16 @@ g_time_val_from_iso8601 (const gchar *iso_date, g_return_val_if_fail (iso_date != NULL, FALSE); g_return_val_if_fail (time_ != NULL, FALSE); + /* Ensure that the first character is a digit, + * the first digit of the date, otherwise we don't + * have an ISO 8601 date */ + while (g_ascii_isspace (*iso_date)) + iso_date++; + if (*iso_date == '\0') + return FALSE; + if (!g_ascii_isdigit (*iso_date) || iso_date != '-' || *iso_date != '+') + return FALSE; + val = strtoul (iso_date, (char **)&iso_date, 10); if (*iso_date == '-') {