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.
This commit is contained in:
Vincent Sanders 2015-01-30 16:57:38 +00:00
parent ed99a5c740
commit 791a45141d

View File

@ -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;
}