From: Frédéric Marchal Date: Wed, 14 Jul 2010 05:48:00 +0000 (+0000) Subject: Don't abort if "onload" or "script" is found in the user agent string. X-Git-Tag: v2.3.1~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d82e81174c6b544f0718736c5f36fda23f63a25b;p=thirdparty%2Fsarg.git Don't abort if "onload" or "script" is found in the user agent string. --- d82e81174c6b544f0718736c5f36fda23f63a25b diff --cc CMakeLists.txt index d91b227,de5081f..dc7cbe2 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@@ -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 462a87d,99ac521..f1c281b --- a/ChangeLog +++ 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 744af77,6bd4ba7..c4021c4 --- a/include/info.h +++ b/include/info.h @@@ -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 b47bfce,b47bfce..492fa8a --- a/useragent.c +++ b/useragent.c @@@ -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); @@@ -101,25 -101,25 +101,21 @@@ 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++; } @@@ -128,7 -128,7 +124,10 @@@ } 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); @@@ -195,14 -195,14 +194,16 @@@ } if(strcmp(user,user_old) != 0) { -- fprintf(fp_ht,"%s%s\n",user,agent); ++ fprintf(fp_ht,"%s",user); ++ output_html_string(fp_ht,agent,250); ++ fputs("\n",fp_ht); strcpy(user_old,user); strcpy(agent_old,agent); -- } else { -- if(strcmp(agent,agent_old) != 0) { -- fprintf(fp_ht,"%s\n",agent); -- strcpy(agent_old,agent); -- } ++ } else if(strcmp(agent,agent_old) != 0) { ++ fputs("",fp_ht); ++ output_html_string(fp_ht,agent,250); ++ fputs("\n",fp_ht); ++ strcpy(agent_old,agent); } } @@@ -235,11 -235,11 +236,11 @@@ 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); } @@@ -262,7 -262,7 +263,10 @@@ 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); @@@ -291,13 -291,13 +295,15 @@@ 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,"%s%d%3.2lf\n",gwarea.current,nagent,perc); ++ fputs("",fp_ht); ++ output_html_string(fp_ht,gwarea.current,250); ++ fprintf(fp_ht,"%d%3.2lf\n",nagent,perc); } fclose(fp_in);