]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the parsing of the sarg log file name
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 8 Jan 2011 20:11:26 +0000 (20:11 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 8 Jan 2011 20:11:26 +0000 (20:11 +0000)
The parsed log file created when parsed_output_log is set is using a
completly numerical date but, when the log file is read again, sarg
expects the month to be a name and therefore reject the file as having
an invalid name.

Thanks to kodemi for identifying the problem.

util.c

diff --git a/util.c b/util.c
index 280746097b6c0ef5cf9aba34e09178adcaa9db81..7c9c58eb8e61567c0d6b671ad4f74fa0676a5441 100644 (file)
--- a/util.c
+++ b/util.c
@@ -718,7 +718,6 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
        const char *str;
        int day0, month0, year0, hour0, minute0;
        int day1, month1, year1, hour1, minute1;
-       char month[4];
        int i;
 
        memset(period,0,sizeof(*period));
@@ -729,11 +728,9 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
                if (!isdigit(str[0]) || !isdigit(str[1])) continue;
                day0=(str[0]-'0')*10+(str[1]-'0');
                str+=2;
-               strncpy(month,str,3);
-               month[3]=0;
-               month0=month2num(month);
+               month0=(str[0]-'0')*10+(str[1]-'0');
                if (month0>=12) continue;
-               str+=3;
+               str+=2;
                year0=0;
                for (i=0 ; isdigit(str[i]) && i<4 ; i++) year0=year0*10+(str[i]-'0');
                if (i!=4) continue;
@@ -754,11 +751,9 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
                if (!isdigit(str[0]) || !isdigit(str[1])) continue;
                day1=(str[0]-'0')*10+(str[1]-'0');
                str+=2;
-               strncpy(month,str,3);
-               month[3]=0;
-               month1=month2num(month);
+               month1=(str[0]-'0')*10+(str[1]-'0');
                if (month1>=12) continue;
-               str+=3;
+               str+=2;
                year1=0;
                for (i=0 ; isdigit(str[i]) && i<4 ; i++) year1=year1*10+(str[i]-'0');
                if (i!=4) continue;