summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorHiltjo Posthuma <hiltjo@codemadness.org>2015-08-07 21:23:58 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2015-08-07 21:23:58 +0200
commite46ef96d680fe3d720a54ff1c178cce03d3a980a (patch)
tree052ae110151e7f27607a8eab79c6b8a16f89f135 /util.c
parentf23af0821309e86d9d6db59796d245b6986e2cd3 (diff)
util: strtotime: stricter time parsing
as input: an empty string or non-digit characters are digits are considered an error now. Still, for the format tools output the formatted time string as time_t 0 on a parse error.
Diffstat (limited to 'util.c')
-rw-r--r--util.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/util.c b/util.c
index a22b235..6f4b04e 100644
--- a/util.c
+++ b/util.c
@@ -188,10 +188,11 @@ int
strtotime(const char *s, time_t *t)
{
long l;
+ char *e;
errno = 0;
- l = strtol(s, NULL, 10);
- if (errno != 0)
+ l = strtol(s, &e, 10);
+ if (*s == '\0' || *e != '\0')
return -1;
if (t)
*t = (time_t)l;