From 97a069df32404705b9c5782cae338a0ea39f4535 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Sat, 28 Jun 2014 15:38:48 +0200 Subject: handle invalid values of strto*l Signed-off-by: Hiltjo Posthuma --- sfeed_stats.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sfeed_stats.c') diff --git a/sfeed_stats.c b/sfeed_stats.c index 3773e4a..a750dc1 100644 --- a/sfeed_stats.c +++ b/sfeed_stats.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "util.h" @@ -40,7 +41,10 @@ main(void) { feeds = fcur; while(parseline(&line, &size, fields, FieldLast, '\t', stdin) > 0) { + errno = 0; parsedtime = (time_t)strtol(fields[FieldUnixTimestamp], NULL, 10); + if(errno != 0) + parsedtime = 0; isnew = (parsedtime >= comparetime) ? 1 : 0; /* first of feed section or new feed section. */ if(!totalfeeds || (fcur && strcmp(fcur->name, fields[FieldFeedName]))) { -- cgit v1.2.3