]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Parse log entries with transferred volume bigger than 2GB
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 7 Feb 2014 10:29:32 +0000 (11:29 +0100)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Fri, 7 Feb 2014 10:29:32 +0000 (11:29 +0100)
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.

log.c

diff --git a/log.c b/log.c
index 213dec618999c9271dd745378ac2d07b2b42f40c..c2a13a1b4ba16642d578deac0ddb509611830295 100644 (file)
--- 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) {