From 9907069f442c56c90b67accb2d8fbd046dfce6db Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 27 Feb 2013 11:00:26 +0100 Subject: Validate date/time when scanning items Bail out when reading dates such as "02/30/2013" from the appointments file. These *could* be converted into valid dates but since we never write invalid dates to that file, these indicate a user error. Fixes following test cases: * appointment-009.sh * appointment-012.sh * appointment-016.sh * appointment-019.sh * event-003.sh Signed-off-by: Lukas Fleischer --- src/apoint.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/apoint.c') diff --git a/src/apoint.c b/src/apoint.c index 889c371..ca400e9 100644 --- a/src/apoint.c +++ b/src/apoint.c @@ -165,6 +165,12 @@ struct apoint *apoint_scan(FILE * f, struct tm start, struct tm end, char state, char buf[BUFSIZ], *newline; time_t tstart, tend; + EXIT_IF(!check_date(start.tm_year, start.tm_mon, start.tm_mday) || + !check_date(end.tm_year, end.tm_mon, end.tm_mday) || + !check_time(start.tm_hour, start.tm_min) || + !check_time(end.tm_hour, end.tm_min), + _("date error in appointment")); + /* Read the appointment description */ if (!fgets(buf, sizeof buf, f)) return NULL; -- cgit v1.2.3-54-g00ecf