Blame SOURCES/netkit-ftp-0.17-arg_max.patch

4f574c
diff -up netkit-ftp-0.17/ftp/glob.c.arg_max netkit-ftp-0.17/ftp/glob.c
4f574c
--- netkit-ftp-0.17/ftp/glob.c.arg_max	2008-04-07 11:41:14.000000000 +0200
4f574c
+++ netkit-ftp-0.17/ftp/glob.c	2008-04-07 12:01:53.000000000 +0200
4f574c
@@ -50,6 +50,7 @@ char glob_rcsid[] = 
4f574c
 #include <stdio.h>
4f574c
 #include <stdlib.h>
4f574c
 #include <string.h>
4f574c
+#include <unistd.h>
4f574c
 
4f574c
 #include "ftp_var.h"  /* for protos only */
4f574c
 #include "glob.h"
4f574c
@@ -57,7 +58,7 @@ char glob_rcsid[] = 
4f574c
 #define	QUOTE 0200
4f574c
 #define	TRIM 0177
4f574c
 #define	eq(a,b)		(strcmp(a, b)==0)
4f574c
-#define	GAVSIZ		(ARG_MAX/6)
4f574c
+#define	GAVSIZ		(sysconf(_SC_ARG_MAX)/6)
4f574c
 #define	isdir(d)	((d.st_mode & S_IFMT) == S_IFDIR)
4f574c
 
4f574c
 const char *globerr;
4f574c
@@ -115,7 +116,7 @@ char **
4f574c
 ftpglob(const char *v)
4f574c
 {
4f574c
 	char agpath[BUFSIZ];
4f574c
-	entry agargv[GAVSIZ];
4f574c
+	entry *agargv;
4f574c
 	centry vv[2];
4f574c
 	vv[0].text = v;
4f574c
 	vv[1].text = NULL;
4f574c
@@ -133,6 +134,8 @@ ftpglob(const char *v)
4f574c
 	/* added ()'s to sizeof, (ambigious math for the compiler) */
4f574c
 	lastgpathp = agpath + (sizeof(agpath)- 2);
4f574c
 
4f574c
+	agargv = (entry *)malloc(sizeof (entry) * GAVSIZ);
4f574c
+	if (agargv == NULL) fatal("Out of memory");
4f574c
 	ginit(agargv); 
4f574c
 	globcnt = 0;
4f574c
 	collect(v);
4f574c
@@ -156,7 +159,7 @@ ginit(entry *agargv)
4f574c
 	gargv = agargv; 
4f574c
 	sortbas = agargv; 
4f574c
 	gargc = 0;
4f574c
-	gnleft = ARG_MAX - 4;
4f574c
+	gnleft = sysconf(_SC_ARG_MAX) - 4;
4f574c
 }
4f574c
 
4f574c
 static 
4f574c
@@ -674,6 +677,7 @@ efree(entry *av) 
4f574c
 {
4f574c
     int i;
4f574c
     for (i=0; av[i].text; i++) free(av[i].text);
4f574c
+    free((void *)av);
4f574c
 }
4f574c
 
4f574c
 static