]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Validate the year extracted from a parsed log file
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 17 Nov 2015 18:30:45 +0000 (19:30 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Tue, 17 Nov 2015 18:30:45 +0000 (19:30 +0100)
A parsed log file name contains the date range covering the log content in
a form like sarg-15062015_0100-15062015_0101.log.gz.

The date was insufficiently validated as any date below 1900 produces
an integer overflow.

util.c

diff --git a/util.c b/util.c
index cdcbf1689649a20158c5511470fc57060903d7f2..3e423b5028dddd647c00fd495ac728787c37dc88 100644 (file)
--- a/util.c
+++ b/util.c
@@ -988,7 +988,7 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
                str+=2;
                year0=0;
                for (i=0 ; isdigit(str[i]) && i<4 ; i++) year0=year0*10+(str[i]-'0');
-               if (i!=4) continue;
+               if (i!=4 || year0<1900) continue;
                str+=4;
                if (str[0]!='_') continue;
                str++;
@@ -1012,7 +1012,7 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
                str+=2;
                year1=0;
                for (i=0 ; isdigit(str[i]) && i<4 ; i++) year1=year1*10+(str[i]-'0');
-               if (i!=4) continue;
+               if (i!=4 || year1<1900) continue;
                str+=4;
 
                if (str[0]!='_') continue;