fix a segmentation fault when you are using authentication and have

a user named "log"; from sarg bugtracker via freebsd
also, fix sprintf and rcs id; from maintainer Douglas Santos
thanks to aanriot@, who found some errors when i merged Douglas
Santos diff
ok aanriot@ and maintainer Douglas Santos
This commit is contained in:
martynas 2007-06-22 12:48:25 +00:00
parent d5b5786a9b
commit cbb6a6bf82
8 changed files with 74 additions and 32 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.6 2007/05/16 15:59:23 aanriot Exp $ # $OpenBSD: Makefile,v 1.7 2007/06/22 12:48:25 martynas Exp $
COMMENT= "Squid Analysis Report Generator" COMMENT= "Squid Analysis Report Generator"
DISTNAME= sarg-2.2.3.1 DISTNAME= sarg-2.2.3.1
PKGNAME= ${DISTNAME}p0
CATEGORIES= www CATEGORIES= www
HOMEPAGE= http://sarg.sourceforge.net/ HOMEPAGE= http://sarg.sourceforge.net/
@ -35,6 +36,7 @@ post-extract:
post-build: post-build:
@perl -pi -e \ @perl -pi -e \
"s,%%SYSCONFDIR%%,${SYSCONFDIR},g" \ "s,%%SYSCONFDIR%%,${SYSCONFDIR},g" \
${WRKSRC}/log.c \
${WRKSRC}/sarg.conf \ ${WRKSRC}/sarg.conf \
${WRKSRC}/sarg.1 ${WRKSRC}/sarg.1

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-configure,v 1.4 2007/05/16 15:59:23 aanriot Exp $ $OpenBSD: patch-configure,v 1.5 2007/06/22 12:48:25 martynas Exp $
--- configure.orig Wed Apr 4 07:28:32 2007 --- configure.orig Tue Jan 2 21:11:26 2007
+++ configure Wed Apr 4 07:29:17 2007 +++ configure Tue Jun 19 20:24:58 2007
@@ -2335,12 +2335,6 @@ @@ -2335,12 +2335,6 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
;; ;;
esac esac
@ -14,7 +14,7 @@ $OpenBSD: patch-configure,v 1.4 2007/05/16 15:59:23 aanriot Exp $
case "$host" in case "$host" in
*-solaris*) *-solaris*)
LDFLAGS="${LDFLAGS} -lsocket -lnsl" LDFLAGS="${LDFLAGS} -lsocket -lnsl"
@@ -3990,7 +3984,7 @@ @@ -3990,7 +3984,7 @@ done
for ac_header in stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \ for ac_header in stdio.h stdlib.h string.h strings.h sys/time.h time.h unistd.h sys/dirent.h \
dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \ dirent.h sys/socket.h netdb.h arpa/inet.h sys/types.h netinet/in.h sys/stat.h \

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-convlog_c,v 1.3 2007/05/16 15:59:23 aanriot Exp $ $OpenBSD: patch-convlog_c,v 1.4 2007/06/22 12:48:25 martynas Exp $
--- convlog.c.orig Tue Nov 29 17:39:45 2005 --- convlog.c.orig Tue Jan 2 21:11:26 2007
+++ convlog.c Thu Jan 26 21:31:44 2006 +++ convlog.c Tue Jun 19 20:24:58 2007
@@ -39,7 +39,7 @@ void convlog(char *arq, char *df, int df @@ -39,7 +39,7 @@ void convlog(char *arq, char *df, int dfrom, int dunti
struct tm *t; struct tm *t;
if(arq[0] == '\0') if(arq[0] == '\0')
@ -10,7 +10,7 @@ $OpenBSD: patch-convlog_c,v 1.3 2007/05/16 15:59:23 aanriot Exp $
if((fp_in=fopen(arq,"r"))==NULL) { if((fp_in=fopen(arq,"r"))==NULL) {
fprintf(stderr, "SARG: (convlog) %s: %s\n",text[8],arq); fprintf(stderr, "SARG: (convlog) %s: %s\n",text[8],arq);
@@ -52,16 +52,16 @@ void convlog(char *arq, char *df, int df @@ -52,16 +52,16 @@ void convlog(char *arq, char *df, int dfrom, int dunti
t=localtime(&tt); t=localtime(&tt);
if(dfrom) { if(dfrom) {

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-log_c,v 1.2 2007/05/16 15:59:23 aanriot Exp $ $OpenBSD: patch-log_c,v 1.3 2007/06/22 12:48:25 martynas Exp $
--- log.c.orig Wed Apr 4 08:25:56 2007 --- log.c.orig Tue Jan 2 21:11:26 2007
+++ log.c Wed Apr 4 08:31:27 2007 +++ log.c Tue Jun 19 20:45:44 2007
@@ -145,7 +145,7 @@ @@ -145,7 +145,7 @@ int main(argc,argv)
SquidGuardLogAlternate[0]='\0'; SquidGuardLogAlternate[0]='\0';
arq[0]='\0'; arq[0]='\0';
@ -10,7 +10,7 @@ $OpenBSD: patch-log_c,v 1.2 2007/05/16 15:59:23 aanriot Exp $
sprintf(ExcludeCodes,"%s/exclude_codes",SYSCONFDIR); sprintf(ExcludeCodes,"%s/exclude_codes",SYSCONFDIR);
strcpy(GraphDaysBytesBarColor,"orange"); strcpy(GraphDaysBytesBarColor,"orange");
strcpy(BgColor,"#ffffff"); strcpy(BgColor,"#ffffff");
@@ -160,7 +160,7 @@ @@ -160,7 +160,7 @@ int main(argc,argv)
strcpy(LogoTextColor,"#006699"); strcpy(LogoTextColor,"#006699");
strcpy(FontSize,"9px"); strcpy(FontSize,"9px");
strcpy(TempDir,"/tmp"); strcpy(TempDir,"/tmp");
@ -19,7 +19,7 @@ $OpenBSD: patch-log_c,v 1.2 2007/05/16 15:59:23 aanriot Exp $
strcpy(Ip2Name,"no"); strcpy(Ip2Name,"no");
strcpy(DateFormat,"u"); strcpy(DateFormat,"u");
strcpy(OverwriteReport,"no"); strcpy(OverwriteReport,"no");
@@ -197,11 +197,11 @@ @@ -197,11 +197,11 @@ int main(argc,argv)
strcpy(ShowSargInfo,"yes"); strcpy(ShowSargInfo,"yes");
strcpy(ShowSargLogo,"yes"); strcpy(ShowSargLogo,"yes");
strcpy(ParsedOutputLog,"no"); strcpy(ParsedOutputLog,"no");
@ -29,7 +29,16 @@ $OpenBSD: patch-log_c,v 1.2 2007/05/16 15:59:23 aanriot Exp $
strcpy(HeaderFontSize,"9px"); strcpy(HeaderFontSize,"9px");
strcpy(TitleFontSize,"11px"); strcpy(TitleFontSize,"11px");
- strcpy(AuthUserFile,"/usr/local/sarg/passwd"); - strcpy(AuthUserFile,"/usr/local/sarg/passwd");
+ strcpy(AuthUserFile,"/etc/sarg/passwd"); + strcpy(AuthUserFile,"%%SYSCONFDIR%%/sarg/passwd");
strcpy(AuthName,"SARG, Restricted Access"); strcpy(AuthName,"SARG, Restricted Access");
strcpy(AuthType,"basic"); strcpy(AuthType,"basic");
strcpy(Require,"require user admin %u"); strcpy(Require,"require user admin %u");
@@ -1216,7 +1216,7 @@ int main(argc,argv)
if(download_flag && strstr(code,"DENIED") == 0) {
ndownload = 1;
- sprintf(bufz, "%s %s %s %s %s %s\n",dia,hora,user,ip,download_url);
+ sprintf(bufz, "%s %s %s %s %s\n",dia,hora,user,ip,download_url);
#ifdef LEGACY_WRITE_DOWNLOAD
sprintf(tmp3,"%s/sarg/download.unsort",tmp);

View File

@ -0,0 +1,31 @@
$OpenBSD: patch-report_c,v 1.1 2007/06/22 12:48:25 martynas Exp $
--- report.c.orig Tue Jan 2 21:11:26 2007
+++ report.c Tue Jun 19 20:26:14 2007
@@ -46,6 +46,7 @@ void gerarel()
long long int incache=0;
long long int oucache=0;
char *s;
+ char *haystack;
DIR *dirp;
struct dirent *direntp;
@@ -73,7 +74,9 @@ void gerarel()
dirp = opendir(tmp);
while ((direntp = readdir( dirp )) != NULL ) {
- if((strstr(direntp->d_name,".log") == 0) ||
+ haystack=direntp->d_name;
+ haystack+=(strlen(haystack)-5);
+ if((strstr(haystack,".log") == 0) ||
(strncmp(direntp->d_name,"download.log",12) == 0) ||
(strncmp(direntp->d_name,"denied.log",10) == 0) ||
(strncmp(direntp->d_name,"authfail.log.unsort",19) == 0))
@@ -89,7 +92,7 @@ void gerarel()
getword(wname2,wdname,'.');
strcat(user,wname2);
- if(strcmp(wdname,"log") !=0) {
+ if((strcmp(wdname,"log")!=0) || (strlen(wdname)>3)) {
strcat(user,".");
goto strip_prefix;
}

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-sarg_1,v 1.1 2006/01/28 21:22:07 aanriot Exp $ $OpenBSD: patch-sarg_1,v 1.2 2007/06/22 12:48:25 martynas Exp $
--- sarg.1.orig Tue Nov 29 17:39:45 2005 --- sarg.1.orig Tue Jan 2 21:11:26 2007
+++ sarg.1 Fri Jan 27 22:47:44 2006 +++ sarg.1 Wed Jun 20 21:25:08 2007
@@ -131,9 +131,9 @@ Convert the logfile's date/time field to @@ -131,9 +131,9 @@ Convert the logfile's date/time field to human-readabl
.B \-split .B \-split
Split the log file by date in \fB-d\fP parameter. Split the log file by date in \fB-d\fP parameter.
.SH FILES .SH FILES

View File

@ -1,7 +1,7 @@
$openBSD$ $OpenBSD: patch-splitlog_c,v 1.4 2007/06/22 12:48:25 martynas Exp $
--- splitlog.c.orig Tue Nov 29 17:39:45 2005 --- splitlog.c.orig Tue Jan 2 21:11:26 2007
+++ splitlog.c Thu Jan 26 21:31:44 2006 +++ splitlog.c Tue Jun 19 20:24:58 2007
@@ -39,7 +39,7 @@ void splitlog(char *arq, char *df, int d @@ -39,7 +39,7 @@ void splitlog(char *arq, char *df, int dfrom, int dunt
struct tm *t; struct tm *t;
if(arq[0] == '\0') if(arq[0] == '\0')
@ -10,7 +10,7 @@ $openBSD$
if((fp_in=fopen(arq,"r"))==NULL) { if((fp_in=fopen(arq,"r"))==NULL) {
fprintf(stderr, "SARG: (splitlog) %s: %s\n",text[8],arq); fprintf(stderr, "SARG: (splitlog) %s: %s\n",text[8],arq);
@@ -52,7 +52,7 @@ void splitlog(char *arq, char *df, int d @@ -52,7 +52,7 @@ void splitlog(char *arq, char *df, int dfrom, int dunt
t=localtime(&tt); t=localtime(&tt);
if(dfrom) { if(dfrom) {
@ -19,7 +19,7 @@ $openBSD$
idata=atoi(wdata); idata=atoi(wdata);
if(idata < dfrom || idata > duntil) if(idata < dfrom || idata > duntil)
continue; continue;
@@ -64,9 +64,9 @@ void splitlog(char *arq, char *df, int d @@ -64,9 +64,9 @@ void splitlog(char *arq, char *df, int dfrom, int dunt
} }
if(strncmp(df,"e",1) == 0) if(strncmp(df,"e",1) == 0)

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-squidguard_log_c,v 1.2 2006/01/28 21:22:07 aanriot Exp $ $OpenBSD: patch-squidguard_log_c,v 1.3 2007/06/22 12:48:25 martynas Exp $
--- squidguard_log.c.orig Tue Nov 29 17:39:45 2005 --- squidguard_log.c.orig Tue Jan 2 21:11:26 2007
+++ squidguard_log.c Thu Jan 26 21:31:44 2006 +++ squidguard_log.c Wed Jun 20 21:25:08 2007
@@ -105,7 +105,7 @@ void read_log(char *wentp, FILE *fp_ou) @@ -148,7 +148,7 @@ void read_log(char *wentp, FILE *fp_ou)
if (strcmp(user,"-") == 0) { if (strcmp(user,"-") == 0) {
strcpy(user,ip); strcpy(user,ip);