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