diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-08-07 21:23:58 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2015-08-07 21:23:58 +0200 |
commit | e46ef96d680fe3d720a54ff1c178cce03d3a980a (patch) | |
tree | 052ae110151e7f27607a8eab79c6b8a16f89f135 /util.c | |
parent | f23af0821309e86d9d6db59796d245b6986e2cd3 (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.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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; |