From 9526b568534577a39ac6810670c9421e5e521da9 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Tue, 8 Apr 2014 14:21:16 +0200 Subject: check mktime Signed-off-by: Hiltjo Posthuma --- sfeed.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sfeed.c b/sfeed.c index f739170..d00ecf9 100644 --- a/sfeed.c +++ b/sfeed.c @@ -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]; -- cgit v1.2.3