]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Parse the time from a common access log
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 15 Apr 2011 11:01:46 +0000 (11:01 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Fri, 15 Apr 2011 11:01:46 +0000 (11:01 +0000)
The time was ignored when parsing a squid log file written with the common
logformat. The consequence was that all the accesses were reported as occuring
at 00:00.

This is a bug introduced in sarg 2.3.

Thanks to Richard P Scott for reporting this bug.

log.c

diff --git a/log.c b/log.c
index 28115b133916cac2869d858ec697a0fa9fde712a..111d9db9ce8f8040677aac6012014e6f0fc6055d 100644 (file)
--- a/log.c
+++ b/log.c
@@ -1010,6 +1010,11 @@ int main(int argc,char *argv[])
                                        imonth=month2num(mes)+1;
                                        idata=builddia(iday,imonth,iyear);
                                        computedate(iyear,imonth,iday,&tt);
+                                       if (sscanf(hora,"%d:%d:%d",&tt.tm_hour,&tt.tm_min,&tt.tm_sec)!=3 || tt.tm_hour<0 || tt.tm_hour>=24 ||
+                                                       tt.tm_min<0 || tt.tm_min>=60 || tt.tm_sec<0 || tt.tm_sec>=60) {
+                                               debuga(_("Invalid time found in %s\n"),arq);
+                                               exit(EXIT_FAILURE);
+                                       }
                                        t=&tt;
                                }