From: Frederic Marchal Date: Fri, 7 Feb 2014 10:29:32 +0000 (+0100) Subject: Parse log entries with transferred volume bigger than 2GB X-Git-Tag: v2.3.9~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8373980e2463b2177eb8ebd327d99c42abe56c11;p=thirdparty%2Fsarg.git Parse log entries with transferred volume bigger than 2GB There was only one place where version 2.3 was unable to cope with transferred data bigger than 2GB. Thanks to Рустам Муса-Ахунов for pointing this bug. --- diff --git a/log.c b/log.c index 213dec6..c2a13a1 100644 --- a/log.c +++ b/log.c @@ -125,7 +125,7 @@ int main(int argc,char *argv[]) int iarq=0; int isa_ncols=0,isa_cols[ISACOL_Last]; int lastlog=-1; - long int nbytes; + long long int nbytes; long int elap_time; bool from_stdin; bool from_pipe; @@ -1430,7 +1430,7 @@ int main(int argc,char *argv[]) if(strcmp(user,"-") ==0 || strcmp(user," ") ==0 || strcmp(user,"") ==0 || strcmp(user,":") ==0) continue; - nbytes=atol(tam); + nbytes=atoll(tam); if (nbytes<0) nbytes=0; elap_time=atol(elap); @@ -1503,14 +1503,14 @@ int main(int argc,char *argv[]) } } - if (fprintf(ufile->file, "%s\t%s\t%s\t%s\t%ld\t%s\t%ld\t%s\n",dia,hora,ip,url,nbytes,code,elap_time,smartfilter)<=0) { + if (fprintf(ufile->file, "%s\t%s\t%s\t%s\t%"PRIi64"\t%s\t%ld\t%s\n",dia,hora,ip,url,nbytes,code,elap_time,smartfilter)<=0) { debuga(_("Write error in the log file of user %s\n"),user); exit(EXIT_FAILURE); } records_kept++; if(fp_log && ilf!=ILF_Sarg) - fprintf(fp_log, "%s\t%s\t%s\t%s\t%s\t%ld\t%s\t%ld\t%s\n",dia,hora,user,ip,url,nbytes,code,elap_time,smartfilter); + fprintf(fp_log, "%s\t%s\t%s\t%s\t%s\t%"PRIi64"\t%s\t%ld\t%s\n",dia,hora,user,ip,url,nbytes,code,elap_time,smartfilter); totregsg++; @@ -1561,7 +1561,7 @@ int main(int argc,char *argv[]) printf("FUNC=\t%s\n",fun); printf("URL=\t%s\n",url); printf("CODE=\t%s\n",code); - printf("LEN=\t%ld\n",nbytes); + printf("LEN=\t%"PRIi64"\n",nbytes); } } if (!from_stdin) {