diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2014-04-08 14:21:16 +0200 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2014-04-08 14:21:16 +0200 |
commit | 9526b568534577a39ac6810670c9421e5e521da9 (patch) | |
tree | f7401ec03ef9288c7263f29c142a1a7745196085 | |
parent | 0e6e10da54b4e49da995a5b91c5654e345dfe323 (diff) |
check mktime
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
-rw-r--r-- | sfeed.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -341,7 +341,7 @@ parsetime(const char *s, char *buf, size_t bufsiz) { NULL }; char *p; - int offset, i; + int i; if(buf) buf[0] = '\0'; @@ -349,20 +349,21 @@ parsetime(const char *s, char *buf, size_t bufsiz) { for(i = 0; i < LEN(formats); i++) { if((p = strptime(s, formats[i], &tm))) { tm.tm_isdst = -1; /* don't use DST */ - t = mktime(&tm); - offset = gettimetz(p, tz, sizeof(tz)); + if((t = mktime(&tm)) == -1) /* error */ + return t; + t -= gettimetz(p, tz, sizeof(tz)); if(buf) snprintf(buf, bufsiz, "%04d-%02d-%02d %02d:%02d:%02d %-.16s", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tz); - t -= offset; break; } } return t; } -static void /* print text, escape tabs, newline and carriage return etc */ +/* print text, escape tabs, newline and carriage return etc */ +static void string_print(String *s) { const char *p; char buffer[BUFSIZ + 4]; |