source: npl/system/netkit-ftp/patches/22-netkit-ftp-0.17-arg_max.patch @ 0105685

gcc484ntopperl-5.22
Last change on this file since 0105685 was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[c5c522c]1diff -up netkit-ftp-0.17/ftp/glob.c.arg_max netkit-ftp-0.17/ftp/glob.c
2--- netkit-ftp-0.17/ftp/glob.c.arg_max  2008-04-07 11:41:14.000000000 +0200
3+++ netkit-ftp-0.17/ftp/glob.c  2008-04-07 12:01:53.000000000 +0200
4@@ -50,6 +50,7 @@ char glob_rcsid[] =
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8+#include <unistd.h>
9 
10 #include "ftp_var.h"  /* for protos only */
11 #include "glob.h"
12@@ -57,7 +58,7 @@ char glob_rcsid[] =
13 #define        QUOTE 0200
14 #define        TRIM 0177
15 #define        eq(a,b)         (strcmp(a, b)==0)
16-#define        GAVSIZ          (ARG_MAX/6)
17+#define        GAVSIZ          (sysconf(_SC_ARG_MAX)/6)
18 #define        isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
19 
20 const char *globerr;
21@@ -115,7 +116,7 @@ char **
22 ftpglob(const char *v)
23 {
24        char agpath[BUFSIZ];
25-       entry agargv[GAVSIZ];
26+       entry *agargv;
27        centry vv[2];
28        vv[0].text = v;
29        vv[1].text = NULL;
30@@ -133,6 +134,8 @@ ftpglob(const char *v)
31        /* added ()'s to sizeof, (ambigious math for the compiler) */
32        lastgpathp = agpath + (sizeof(agpath)- 2);
33 
34+       agargv = (entry *)malloc(sizeof (entry) * GAVSIZ);
35+       if (agargv == NULL) fatal("Out of memory");
36        ginit(agargv);
37        globcnt = 0;
38        collect(v);
39@@ -156,7 +159,7 @@ ginit(entry *agargv)
40        gargv = agargv;
41        sortbas = agargv;
42        gargc = 0;
43-       gnleft = ARG_MAX - 4;
44+       gnleft = sysconf(_SC_ARG_MAX) - 4;
45 }
46 
47 static
48@@ -674,6 +677,7 @@ efree(entry *av)
49 {
50     int i;
51     for (i=0; av[i].text; i++) free(av[i].text);
52+    free((void *)av);
53 }
54 
55 static
Note: See TracBrowser for help on using the repository browser.