]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Fix the month numbers read from a sarg log
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 12 Jan 2011 15:05:10 +0000 (15:05 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 12 Jan 2011 15:05:10 +0000 (15:05 +0000)
The month numbers parsed from a sarg log file name were in the range 1
to 12 but they must be in the range 0 to 11. This problem has been
fixed thanks to Denis Konchekov.

In addition, the numerical values of the days and months parsed from
the sarg log file name are more strictly validated.

CMakeLists.txt
include/info.h
util.c

index aea8d37419cdb8681f0e4cb130343d95fffc299c..c6402abb76e2f238b6f620a716e3da3a2eee92eb 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION "3.2-pre1")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Dec-27-2010")
+SET(sarg_BUILDDATE "Jan-12-2011")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index f74bc7ffa21e0f3cebfcbe74d1965c39df5d67a1..24b659d8e44766a8aabacfac42876fbaa12c2245 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Dec-27-2010"
+#define VERSION PACKAGE_VERSION" Jan-12-2011"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/util.c b/util.c
index 7c9c58eb8e61567c0d6b671ad4f74fa0676a5441..faf249210686d05f4930420c27d0c0f23ed81918 100644 (file)
--- a/util.c
+++ b/util.c
@@ -727,9 +727,10 @@ int getperiod_fromsarglog(const char *arqtt,struct periodstruct *period)
                str+=5;
                if (!isdigit(str[0]) || !isdigit(str[1])) continue;
                day0=(str[0]-'0')*10+(str[1]-'0');
+               if (day0<1 || day0>31) continue;
                str+=2;
-               month0=(str[0]-'0')*10+(str[1]-'0');
-               if (month0>=12) continue;
+               month0=(str[0]-'0')*10+(str[1]-'0')-1;
+               if (month0<0 || month0>11) continue;
                str+=2;
                year0=0;
                for (i=0 ; isdigit(str[i]) && i<4 ; i++) year0=year0*10+(str[i]-'0');
@@ -750,9 +751,10 @@ 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');
+               if (day1<1 || day1>31) continue;
                str+=2;
-               month1=(str[0]-'0')*10+(str[1]-'0');
-               if (month1>=12) continue;
+               month1=(str[0]-'0')*10+(str[1]-'0')-1;
+               if (month1<0 || month1>11) continue;
                str+=2;
                year1=0;
                for (i=0 ; isdigit(str[i]) && i<4 ; i++) year1=year1*10+(str[i]-'0');