From: Frédéric Marchal Date: Sat, 1 Aug 2009 20:24:19 +0000 (+0000) Subject: Fixed bug #1740268. X-Git-Tag: v2_2_6~47 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5160b452920b8f896251e70c850cd7cfbc65f12e;p=thirdparty%2Fsarg.git Fixed bug #1740268. --- diff --git a/include/info.h b/include/info.h index 6c412b4..4d7e332 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION PACKAGE_VERSION" Jul-20-2009" +#define VERSION PACKAGE_VERSION" Aug-01-2009" #define PGM PACKAGE_NAME #define URL "http://sarg.sourceforge.net" diff --git a/log.c b/log.c index 52b5da9..2f0bc62 100644 --- a/log.c +++ b/log.c @@ -107,7 +107,7 @@ int main(int argc,char *argv[]) int narq=0; int iarq=0; int exstring=0; - int i0=0,i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0; + int i0=0,i1=-1,i2=-1,i3=-1,i4=-1,i5=-1,i6=-1,i7=-1,i8=-1; long totregsl=0; long totregsg=0; long totregsx=0; @@ -925,12 +925,12 @@ int main(int argc,char *argv[]) printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); exit(1); } - while(strstr(bufz,"\t") != 0) { - if (getword(val1,sizeof(val1),bufz,'\t')<0){ + fixendofline(bufz); + while(bufz[0] != '\0') { + if (getword(val1,sizeof(val1),bufz,'\t')<0){ printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); exit(1); } - i0++; if(strcmp(val1,"c-ip") == 0) i1=i0; if(strcmp(val1,"cs-username") == 0) i2=i0; if(strcmp(val1,"date") == 0) i3=i0; @@ -939,63 +939,67 @@ int main(int argc,char *argv[]) if(strcmp(val1,"sc-bytes") == 0) i6=i0; if(strcmp(val1,"cs-uri") == 0) i7=i0; if(strcmp(val1,"sc-status") == 0) i8=i0; + i0++; } - } - fgets(bufz,sizeof(bufz),fp_in); - strcpy(val1,bufz); - for(x=0; x<=i1-1; x++) { - if (getword3(ip,sizeof(ip),val1,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); - exit(1); - } - } - strcpy(val1,bufz); - for(x=0; x<=i2-1; x++) { - if (getword3(user,sizeof(user),val1,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); - exit(1); - } - } - strcpy(val1,bufz); - for(x=0; x<=i3-1; x++) { - if (getword3(data,sizeof(data),val1,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); - exit(1); - } - } - strcpy(val1,bufz); - for(x=0; x<=i4-1; x++) { - if (getword3(hora,sizeof(hora),val1,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); - exit(1); - } - } - strcpy(val1,bufz); - for(x=0; x<=i5-1; x++) { - if (getword3(elap,sizeof(elap),val1,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); - exit(1); + if (i1<0) { + // not the line we are looking for + i0=0; } } - strcpy(val1,bufz); - for(x=0; x<=i6-1; x++) { - if (getword3(tam,sizeof(tam),val1,'\t')<0) { - printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",arq); - exit(1); - } - } - strcpy(val1,bufz); - for(x=0; x<=i7-1; x++) { - if (getword3(url,sizeof(url),val1,'\t')<0) { + fgets(bufz,sizeof(bufz),fp_in); + for (x=0 ; x=sizeof(ip)) { + printf("SARG: Maybe you have a broken IP in your %s file.\n",arq); + exit(1); + } + strcpy(ip,val1); + } else if (x==i2) { + if (strlen(val1)>=sizeof(user)) { + printf("SARG: Maybe you have a broken user in your %s file.\n",arq); + exit(1); + } + strcpy(user,val1); + } else if (x==i3) { + if (strlen(val1)>=sizeof(data)) { + printf("SARG: Maybe you have a broken date in your %s file.\n",arq); + exit(1); + } + strcpy(data,val1); + } else if (x==i4) { + if (strlen(val1)>=sizeof(hora)) { + printf("SARG: Maybe you have a broken time in your %s file.\n",arq); + exit(1); + } + strcpy(hora,val1); + } else if (x==i5) { + if (strlen(val1)>=sizeof(elap)) { + printf("SARG: Maybe you have a broken download duration in your %s file.\n",arq); + exit(1); + } + strcpy(elap,val1); + } else if (x==i6) { + if (strlen(val1)>=sizeof(tam)) { + printf("SARG: Maybe you have a broken download size in your %s file.\n",arq); + exit(1); + } + strcpy(tam,val1); + } else if (x==i7) { + if (strlen(val1)>=sizeof(url)) { + printf("SARG: Maybe you have a broken URL in your %s file.\n",arq); + exit(1); + } + strcpy(url,val1); + } else if (x==i8) { + if (strlen(val1)>=sizeof(code)) { + printf("SARG: Maybe you have a broken access code in your %s file.\n",arq); + exit(1); + } + strcpy(code,val1); } } @@ -1017,6 +1021,7 @@ int main(int argc,char *argv[]) } if(strlen(user) > 150) { + if (debugm) printf("User too long: %s\n",user); totregsx++; continue; } @@ -1029,6 +1034,7 @@ int main(int argc,char *argv[]) } if(vercode(code)) { + if (debugm) printf("Excluded code: %s\n",code); totregsx++; continue; } @@ -1096,6 +1102,7 @@ int main(int argc,char *argv[]) exit(1); } if (!strchr(url,'/')) { + if (debugm) printf("URL without directory: %s\n",url); totregsx++; continue; } @@ -1197,8 +1204,10 @@ int main(int argc,char *argv[]) if(fhost) { // l=vhexclude(excludefile,ip); l=vhexclude(excludefile,url); - if(!l) + if(!l) { + if (debugm) printf("Excluded site: %s\n",url); totregsx++; + } } } @@ -1260,8 +1269,10 @@ int main(int argc,char *argv[]) if(l) { if(fuser) { l=vuexclude(excludeuser,user); - if(!l) + if(!l) { + if (debugm) printf("Excluded user: %s\n",user); totregsx++; + } } } diff --git a/report.c b/report.c index 8b720f6..eefc614 100644 --- a/report.c +++ b/report.c @@ -29,10 +29,10 @@ static void maketmp(const char *user, const char *dirname, int debug, int indexonly); static void maketmp_hour(const char *user, const char *dirname, int indexonly); static void gravatmp_hora(const char *dirname, const char *user, const char *data, const char *hora, const char *elap, const char *accbytes, int indexonly); -static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache); -static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly); -static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache); -static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart); +static void gravatmpf(const char *oldaccuser, const char *dirname, const char *oldurl, long long int nacc, long long int nbytes, const char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache); +static void gravaporuser(const char *user, const char *dirname, const char *url, const char *ip, const char *data, const char *hora, const char *tam, const char *elap, int indexonly); +static void gravager(char *dirname, const char *user, long long int nacc, const char *url, long long int nbytes, const char *ip, const char *hora, const char *dia, long long int nelap, long long int incache, long long int oucache); +static void grava_SmartFilter(const char *dirname, const char *user, const char *ip, const char *data, const char *hora, const char *url, const char *smart); void gerarel(void) { @@ -500,7 +500,7 @@ static void gravatmp_hora(const char *dirname, const char *user, const char *dat } -static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *data, char *hora, char *tam, char *elap, int indexonly) +static void gravaporuser(const char *user, const char *dirname, const char *url, const char *ip, const char *data, const char *hora, const char *tam, const char *elap, int indexonly) { FILE *fp_ou; @@ -528,7 +528,7 @@ static void gravaporuser(char *user, char *dirname, char *url, char *ip, char *d } -static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long int nacc, long long int nbytes, char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache) +static void gravatmpf(const char *oldaccuser, const char *dirname, const char *oldurl, long long int nacc, long long int nbytes, const char *oldmsg, long long int nelap, int indexonly, long long int incache, long long int oucache) { FILE *fp_ou; @@ -560,7 +560,7 @@ static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long i if(fp_tt) { fputs("\n",fp_tt); - fputs("\n",fp_tt); + fputs("\n\n",fp_tt); fclose(fp_tt); } @@ -569,7 +569,7 @@ static void gravatmpf(char *oldaccuser, char *dirname, char *oldurl, long long i } -static void gravager(char *dirname, char *user, long long int nacc, char *url, long long int nbytes, char *ip, char *hora, char *dia, long long int nelap, long long int incache, long long int oucache) +static void gravager(char *dirname, const char *user, long long int nacc, const char *url, long long int nbytes, const char *ip, const char *hora, const char *dia, long long int nelap, long long int incache, long long int oucache) { FILE *fp_ou; @@ -594,7 +594,7 @@ static void gravager(char *dirname, char *user, long long int nacc, char *url, l } -static void grava_SmartFilter(char *dirname, char *user, char *ip, char *data, char *hora, char *url, char *smart) +static void grava_SmartFilter(const char *dirname, const char *user, const char *ip, const char *data, const char *hora, const char *url, const char *smart) { FILE *fp_ou;