summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorVincent Sanders <vince@kyllikki.org>2015-01-30 16:57:38 +0000
committerVincent Sanders <vince@kyllikki.org>2015-01-30 17:04:34 +0000
commit791a45141da57497db04fad3589853ab5fe36f88 (patch)
tree2c1cff05ae5d363852573efa6088eb03aa9978cc /utils
parented99a5c7400de03e39ee9042b5374e368c78c871 (diff)
downloadnetsurf-791a45141da57497db04fad3589853ab5fe36f88.tar.gz
netsurf-791a45141da57497db04fad3589853ab5fe36f88.tar.bz2
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.
Diffstat (limited to 'utils')
-rw-r--r--utils/utils.c7
1 files changed, 5 insertions, 2 deletions
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;
}