From: Frederic Marchal Date: Tue, 14 Jul 2015 18:25:59 +0000 (+0200) Subject: Properly limit the redirector log to the date range covered by the access log X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2f2e57cc9c38fff4ce6e1a194c2c06a9e3dae6a9;p=thirdparty%2Fsarg.git Properly limit the redirector log to the date range covered by the access log If no date range are provided on the command line, the redirector log would contain the whole content of the blocked log. This patch limit the content of the redirector log to the date range found in the access.log. --- diff --git a/redirector.c b/redirector.c index 4a60629..d52f4ba 100644 --- a/redirector.c +++ b/redirector.c @@ -35,7 +35,7 @@ static int RedirectorErrors=0; //! The file containing the sorted entries. static char redirector_sorted[MAXLEN]=""; -static void parse_log(FILE *fp_ou,char *buf) +static void parse_log(FILE *fp_ou,char *buf,int dfrom,int duntil) { char leks[5], sep[2], res[MAXLEN]; char hour[15]; @@ -180,7 +180,7 @@ static void parse_log(FILE *fp_ou,char *buf) //sprintf(warea,"%04d%02d%02d",year,mon,day); - if (RedirectorFilterOutDate && (dfrom!=0 || duntil!=0)) { + if (RedirectorFilterOutDate) { idata = year*10000+mon*100+day; if(idata < dfrom || idata > duntil) return; @@ -275,7 +275,7 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil) } while ((buf=longline_read(fp_in,line)) != NULL) { - parse_log(fp_ou,buf); + parse_log(fp_ou,buf,dfrom,duntil); } if (FileObject_Close(fp_in)) { debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),wentp,FileObject_GetLastCloseError());