]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - log.c
Applied an extended version of debian patch: opensuse_5_limit_sprintf.patch
[thirdparty/sarg.git] / log.c
diff --git a/log.c b/log.c
index 58100b0f560ef12d8d06b8568bb265325a9402de..eb27ac3b3358cc82e2d3925d715f1bbdcd638394 100644 (file)
--- a/log.c
+++ b/log.c
@@ -422,8 +422,7 @@ int main(int argc,char *argv[])
 
    if(ConfigFile[0] == '\0') sprintf(ConfigFile,"%s/sarg.conf",SYSCONFDIR);
    if(access(ConfigFile, R_OK) != 0) {
-      sprintf(msg,"Cannot open config file: %s - %s",ConfigFile,strerror(errno));
-      debuga(msg);
+      debuga("Cannot open config file: %s - %s",ConfigFile,strerror(errno));
       exit(1);
    }
 
@@ -483,8 +482,7 @@ int main(int argc,char *argv[])
       strcpy(hexclude,ExcludeHosts);
    if(strlen(hexclude) > 0) {
       if(access(hexclude, R_OK) != 0) {
-         sprintf(msg,"Cannot open exclude_hosts file: %s - %s",hexclude,strerror(errno));
-         debuga(msg);
+         debuga("Cannot open exclude_hosts file: %s - %s",hexclude,strerror(errno));
          exit(1);
       }
       gethexclude(hexclude,debug);
@@ -648,10 +646,8 @@ int main(int argc,char *argv[])
       printf("Language=%s\n\n",text[3]);
    }
 
-   if(debug){
-      sprintf(msg,"sarg %s: %s",text[73],VERSION);
-      debuga(msg);
-   }
+   if(debug)
+      debuga("sarg %s: %s",text[73],VERSION);
 
    if (strlen(Ulimit) > 0) {
 #if defined(RLIMIT_NOFILE)
@@ -670,15 +666,12 @@ int main(int argc,char *argv[])
  #elif defined(RLIMIT_OFILE)
          if(setrlimit (RLIMIT_OFILE, &rl) == -1) {
  #endif
-            sprintf(msg,"setrlimit error - %s\n",strerror(errno));
-            debuga(msg);
+            debuga("setrlimit error - %s\n",strerror(errno));
          }
       }
 
-      if(debug) {
-         sprintf(msg,"Maximum file descriptor: cur=%ld max=%ld, changed to cur="RLIM_STRING" max="RLIM_STRING,l1,l2,rl.rlim_cur,rl.rlim_max);
-         debuga(msg);
-      }
+      if(debug)
+         debuga("Maximum file descriptor: cur=%ld max=%ld, changed to cur="RLIM_STRING" max="RLIM_STRING,l1,l2,rl.rlim_cur,rl.rlim_max);
    }
 
    read_usertab(UserTabFile);
@@ -692,10 +685,8 @@ int main(int argc,char *argv[])
 
       strcpy(arqtt,arq);
       decomp(arq,zip,tmp);
-      if(debug) {
-         sprintf(msg, "%s: %s",text[7],arq);
-         debuga(msg);
-      }
+      if(debug)
+         debuga("%s: %s",text[7],arq);
 
       if((fp_in=MY_FOPEN(arq,"r"))==NULL) {
          fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[8],arq,strerror(errno));
@@ -1144,23 +1135,23 @@ int main(int argc,char *argv[])
                tt=atoi(data);
                t=localtime(&tt);
 
-               strftime(tbuf2, 127, "%H%M", t);
+               strftime(tbuf2, sizeof(tbuf2), "%H%M", t);
                if(strncmp(df,"u",1) == 0)
-                  strftime(tbuf, 127, "%Y%b%d", t);
+                  strftime(tbuf, sizeof(tbuf), "%Y%b%d", t);
                if(strncmp(df,"e",1) == 0)
-                  strftime(tbuf, 127, "%d%b%Y", t);
+                  strftime(tbuf, sizeof(tbuf), "%d%b%Y", t);
                if(strncmp(df,"w",1) == 0) {
                   strcpy(IndexTree,"file");
-                  strftime(tbuf, 127, "%Y.%U", t);
+                  strftime(tbuf, sizeof(tbuf), "%Y.%U", t);
                }
 
-               strftime(dia, 127, "%d/%m/%Y", t);
-               strftime(wdata, 127, "%Y%m%d", t);
+               strftime(dia, sizeof(dia), "%d/%m/%Y", t);
+               strftime(wdata, sizeof(wdata), "%Y%m%d", t);
 
                idata=atoi(wdata);
 
                if(strncmp(df,"u",1)==0)
-                  strftime(dia, 127, "%m/%d/%Y", t);
+                  strftime(dia, sizeof(dia), "%m/%d/%Y", t);
                sprintf(hora,"%02d:%02d:%02d",t->tm_hour,t->tm_min,t->tm_sec);
             } else {
                strcpy(wtemp,data+1);
@@ -1186,9 +1177,9 @@ int main(int argc,char *argv[])
                }
 
                if(strcmp(df,"u") == 0)
-                  sprintf(tbuf,"%s%s%s",ano,mes,dia);
+                  snprintf(tbuf,sizeof(tbuf),"%s%s%s",ano,mes,dia);
                if(strcmp(df,"e") == 0)
-                  sprintf(tbuf,"%s%s%s",dia,mes,ano);
+                  snprintf(tbuf,sizeof(tbuf),"%s%s%s",dia,mes,ano);
                builddia(dia,mes,ano,df,wdata);
                idata=atoi(wdata);
             }
@@ -1420,20 +1411,19 @@ int main(int argc,char *argv[])
      fclose (fp_Write_User);
 
    if(debug) {
-      sprintf(msg, "   %s: %ld, %s: %ld, %s: %ld",text[10],totregsl,text[11],totregsg,text[68],totregsx);
-      debuga(msg);
+      debuga("   %s: %ld, %s: %ld, %s: %ld",text[10],totregsl,text[11],totregsg,text[68],totregsx);
 
       if((common_log) && (squid_log))
-         debuga(text[12]);
+         debuga("%s",text[12]);
 
       if((common_log) && (!squid_log)) 
-         debuga(text[13]);
+         debuga("%s",text[13]);
 
       if((!common_log) && (squid_log))
-         debuga(text[14]);
+         debuga("%s",text[14]);
 
       if(sarglog)
-         debuga(text[124]);
+         debuga("%s",text[124]);
 
       if((!common_log) && (!squid_log) && (!sarglog) && (!isalog)) {
          if(!totregsg) {
@@ -1477,10 +1467,8 @@ int main(int argc,char *argv[])
       debugaz("period",period);
    }
 
-   if(debug){
-     sprintf(msg, "%s: %s",text[17],period);
-     debuga(msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[17],period);
 
    fclose(fp_in);
 //   fclose(fp_ou);
@@ -1514,10 +1502,8 @@ int main(int argc,char *argv[])
          }
       }
 
-      if(debug) {
-         sprintf(msg,"%s %s",text[123],arq_log);
-         debuga(msg);
-      }
+      if(debug)
+         debuga("%s %s",text[123],arq_log);
    }
 
    if(strstr(ReportType,"denied") != 0) {
@@ -1562,7 +1548,7 @@ int main(int argc,char *argv[])
       free(excludeuser);
 
    if(debug)
-      debuga(text[21]);
+      debuga("%s",text[21]);
 
    exit(0);
 
@@ -1574,14 +1560,11 @@ static void getusers(const char *pwdfile, int debug)
 
    FILE *fp_usr;
    char buf[255];
-   char Msg[255];
    char *str;
    unsigned long int nreg=0;
 
-   if(debug) {
-      sprintf(Msg,"%s: %s",text[60],pwdfile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[60],pwdfile);
 
    if ((fp_usr = fopen(pwdfile, "r")) == NULL) {
       fprintf(stderr, "SARG: (getusers) %s: %s - %s\n",text[45],pwdfile,strerror(errno));
@@ -1622,13 +1605,10 @@ void gethexclude(char *hexfile, int debug)
 
    FILE *fp_ex;
    char buf[255];
-   char Msg[255];
    unsigned long int nreg=0;
 
-   if(debug) {
-      sprintf(Msg,"%s: %s",text[67],hexfile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[67],hexfile);
 
    if ((fp_ex = fopen(hexfile, "r")) == NULL) {
       fprintf(stderr, "SARG: (gethexclude) %s: %s - %s\n",text[45],hexfile,strerror(errno));
@@ -1667,13 +1647,10 @@ void getuexclude(char *uexfile, int debug)
 
    FILE *fp_ex;
    char buf[255];
-   char Msg[255];
    unsigned long int nreg=0;
 
-   if(debug) {
-      sprintf(Msg,"%s: %s",text[67],uexfile);
-      debuga(Msg);
-   }
+   if(debug)
+      debuga("%s: %s",text[67],uexfile);
 
    if ((fp_ex = fopen(uexfile, "r")) == NULL) {
       fprintf(stderr, "SARG: (gethexclude) %s: %s - %s\n",text[45],uexfile,strerror(errno));