From cbe0740f77270e6f2593a0540fb4f90c39864bf3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Wed, 12 Jan 2011 15:05:10 +0000 Subject: [PATCH] Fix the month numbers read from a sarg log 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 | 2 +- include/info.h | 2 +- util.c | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aea8d37..c6402ab 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/include/info.h b/include/info.h index f74bc7f..24b659d 100755 --- a/include/info.h +++ b/include/info.h @@ -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 7c9c58e..faf2492 100644 --- 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'); -- 2.47.2