From 791a45141da57497db04fad3589853ab5fe36f88 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Fri, 30 Jan 2015 16:57:38 +0000 Subject: Updated time_t fallback reading to not fail if the value is 0 The non strptime fallback reading of time_t values would report faliure if the value it read was 0 which is a valid time. This fixes this path to only fail if there was an actual error processing the value. --- utils/utils.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'utils/utils.c') diff --git a/utils/utils.c b/utils/utils.c index 6730c9fa1..d677295fe 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -595,14 +595,17 @@ nserror nsc_snptimet(char *str, size_t size, time_t *timep) time_t time_out; #ifndef HAVE_STRPTIME + char *rstr; if (size < 1) { return NSERROR_BAD_PARAMETER; } - time_out = (time_t)strtoll(str, NULL, 10); + errno = 0; + time_out = (time_t)strtoll(str, &rstr, 10); - if (time_out == 0) { + /* The conversion may have a range faliure or no digits were found */ + if ((errno != 0) || (rstr == str)) { return NSERROR_BAD_PARAMETER; } -- cgit v1.2.3