]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't abort if "onload" or "script" is found in the user agent string.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 14 Jul 2010 05:48:00 +0000 (05:48 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 14 Jul 2010 05:48:00 +0000 (05:48 +0000)
1  2 
CMakeLists.txt
ChangeLog
include/info.h
useragent.c

diff --cc CMakeLists.txt
index d91b227a9d63d908f70172f5a35b6e295d2f7a30,de5081ff6bdd503fc4038d02da4c7f1da748e3bb..dc7cbe2b56da52b3c24f6ae750138d668b6d01c9
@@@ -1,9 -1,9 +1,9 @@@
  CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
  PROJECT(sarg C)
  SET(sarg_VERSION 2)
 -SET(sarg_REVISION "3")
 +SET(sarg_REVISION "3.1-pre1")
  SET(sarg_BUILD "")
- SET(sarg_BUILDDATE "Jul-12-2010")
 -SET(sarg_BUILDDATE "Jun-21-2010")
++SET(sarg_BUILDDATE "Jul-14-2010")
  
  INCLUDE(AddFileDependencies)
  INCLUDE(CheckIncludeFile)
diff --cc ChangeLog
index 462a87d14ccb0f12b9c1d9c4859c62530b43d158,99ac52198bbecab687ddd82ac503a2c916c78188..f1c281b57a2b4c4f2243397e1ec9d9bd3239134a
+++ b/ChangeLog
@@@ -1,9 -1,6 +1,10 @@@
  SARG ChangeLog
  
- Jul-12-2010 Version 2.3.1
 -Jun-21-2009 Version 2.3
++Jul-14-2010 Version 2.3.1
 +              - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway.
++              - Don't abort if "onload" or "script" is found in the user agent string.
 +
 +Jun-21-2010 Version 2.3
                - LDAP usertab added. 
                  Now you can have your users in a LDAP Server.
                  Use these tags in sarg.conf: LDAPHost, LDAPPort, LDAPBindDN, LDAPBindPW,
diff --cc include/info.h
index 744af770d59823a84b9de3bbb0a1ba2bf856b472,6bd4ba78304ffd861a8e7c920f2e67c18fa07d32..c4021c4f99dee2eae9c20f8f98649768aa4a674d
@@@ -1,3 -1,3 +1,3 @@@
- #define VERSION PACKAGE_VERSION" Jul-12-2010"
 -#define VERSION PACKAGE_VERSION" Jun-21-2010"
++#define VERSION PACKAGE_VERSION" Jul-14-2010"
  #define PGM PACKAGE_NAME
  #define URL "http://sarg.sourceforge.net"
diff --cc useragent.c
index b47bfced4973bb79718839403f720e9738f1a789,b47bfced4973bb79718839403f720e9738f1a789..492fa8af5c3c74d500f6df959bceb528ef7cc1e6
@@@ -59,8 -59,8 +59,8 @@@ void useragent(void
     ipbefore[0]='\0';
     namebefore[0]='\0';
  
--   sprintf(tmp3,"%s/squagent.unsort",TempDir);
--   sprintf(tmp2,"%s/squagent.log",TempDir);
++   sprintf(tmp3,"%s/sarg/squagent.unsort",TempDir);
++   sprintf(tmp2,"%s/sarg/squagent.log",TempDir);
  
     if((fp_in=fopen(UserAgentLog,"r"))==NULL) {
        debuga(_("(useragent) Cannot open file %s\n"),UserAgentLog);
           debuga(_("Maybe you have a broken useragent entry in your %s file\n"),UserAgentLog);
           exit(EXIT_FAILURE);
        }
--      strcpy(warea,agent);
--      strup(warea);
--      if(strstr(warea,"SCRIPT") != 0 || strstr(warea,"ONLOAD") != 0)
--         baddata();
  
        if(gwarea.current[0]!='\0') {
           if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,'\n')<0) {
              debuga(_("Maybe you have a broken record or garbage in your %s file\n"),UserAgentLog);
              exit(EXIT_FAILURE);
           }
--      }
--
--      if(user[0] == '-')
--         strcpy(user,ip);
--      if(user[0] == '\0')
++         if(user[0] == '-')
++            strcpy(user,ip);
++         if(user[0] == '\0')
++            strcpy(user,ip);
++      } else {
           strcpy(user,ip);
++      }
  
        fprintf(fp_ou,"%s\t%s\t%s\n",ip,agent,user);
--      user[0]='\0';
        useragent_count++;
     }
  
     }
  
     fclose(fp_in);
--   fclose(fp_ou);
++   if (fclose(fp_ou)==EOF) {
++      debuga(_("Failed to close file %s - %s\n"),tmp3,strerror(errno));
++      exit(EXIT_FAILURE);
++   }
  
     if(debug) {
        debuga(_("Sorting file: %s\n"),tmp2);
        }
  
        if(strcmp(user,user_old) != 0) {
--         fprintf(fp_ht,"<tr><td class=\"data2\">%s</td><td class=\"data2\">%s</td></tr>\n",user,agent);
++         fprintf(fp_ht,"<tr><td class=\"data2\">%s</td><td class=\"data2\">",user);
++         output_html_string(fp_ht,agent,250);
++         fputs("</td></tr>\n",fp_ht);
           strcpy(user_old,user);
           strcpy(agent_old,agent);
--      } else {
--         if(strcmp(agent,agent_old) != 0) {
--            fprintf(fp_ht,"<tr><td></td><td class=\"data2\">%s</td></tr>\n",agent);
--            strcpy(agent_old,agent);
--         }
++      } else if(strcmp(agent,agent_old) != 0) {
++         fputs("<tr><td></td><td class=\"data2\">",fp_ht);
++         output_html_string(fp_ht,agent,250);
++         fputs("</td></tr>\n",fp_ht);
++         strcpy(agent_old,agent);
        }
     }
  
     while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
        getword_start(&gwarea,buf);
        if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
--         debuga(_("There is an invalid IP address in file %s\n"),tmp);
++         debuga(_("There is an invalid IP address in file %s\n"),tmp3);
           exit(EXIT_FAILURE);
        }
        if (getword(agent,sizeof(agent),&gwarea,'\t')<0) {
--         debuga(_("There is an invalid useragent in file %s\n"),tmp);
++         debuga(_("There is an invalid useragent in file %s\n"),tmp3);
           exit(EXIT_FAILURE);
        }
  
     agentot2+=agentot;
  
     fclose(fp_in);
--   fclose(fp_ou);
++   if (fclose(fp_ou)==EOF) {
++      debuga(_("Failed to close file %s - %s\n"),tmp3,strerror(errno));
++      exit(EXIT_FAILURE);
++   }
  
     unlink(tmp3);
  
        fixendofline(buf);
        getword_start(&gwarea,buf);
        if (getword(tagent,sizeof(tagent),&gwarea,' ')<0) {
--         debuga(_("There is an invalid useragent in file %s\n"),tmp);
++         debuga(_("There is an invalid useragent in file %s\n"),tmp3);
           exit(EXIT_FAILURE);
        }
        nagent=atoi(tagent);
        perc=(agentot2>0) ? nagent * 100. / agentot2 : 0.;
  
--      fprintf(fp_ht,"<tr><td class=\"data2\">%s</td><td class=\"data\">%d</td><td class=\"data\">%3.2lf</td></tr>\n",gwarea.current,nagent,perc);
++      fputs("<tr><td class=\"data2\">",fp_ht);
++      output_html_string(fp_ht,gwarea.current,250);
++      fprintf(fp_ht,"</td><td class=\"data\">%d</td><td class=\"data\">%3.2lf</td></tr>\n",nagent,perc);
     }
     fclose(fp_in);