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

Last change on this file since 7c410f9 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
  • netkit-ftp-0.17/ftp/glob.c

    diff -up netkit-ftp-0.17/ftp/glob.c.arg_max netkit-ftp-0.17/ftp/glob.c
    old new char glob_rcsid[] =  
    5050#include <stdio.h>
    5151#include <stdlib.h>
    5252#include <string.h>
     53#include <unistd.h>
    5354
    5455#include "ftp_var.h"  /* for protos only */
    5556#include "glob.h"
    char glob_rcsid[] =  
    5758#define QUOTE 0200
    5859#define TRIM 0177
    5960#define eq(a,b)         (strcmp(a, b)==0)
    60 #define GAVSIZ          (ARG_MAX/6)
     61#define GAVSIZ          (sysconf(_SC_ARG_MAX)/6)
    6162#define isdir(d)        ((d.st_mode & S_IFMT) == S_IFDIR)
    6263
    6364const char *globerr;
    char ** 
    115116ftpglob(const char *v)
    116117{
    117118        char agpath[BUFSIZ];
    118         entry agargv[GAVSIZ];
     119        entry *agargv;
    119120        centry vv[2];
    120121        vv[0].text = v;
    121122        vv[1].text = NULL;
    ftpglob(const char *v) 
    133134        /* added ()'s to sizeof, (ambigious math for the compiler) */
    134135        lastgpathp = agpath + (sizeof(agpath)- 2);
    135136
     137        agargv = (entry *)malloc(sizeof (entry) * GAVSIZ);
     138        if (agargv == NULL) fatal("Out of memory");
    136139        ginit(agargv);
    137140        globcnt = 0;
    138141        collect(v);
    ginit(entry *agargv) 
    156159        gargv = agargv;
    157160        sortbas = agargv;
    158161        gargc = 0;
    159         gnleft = ARG_MAX - 4;
     162        gnleft = sysconf(_SC_ARG_MAX) - 4;
    160163}
    161164
    162165static
    efree(entry *av)  
    674677{
    675678    int i;
    676679    for (i=0; av[i].text; i++) free(av[i].text);
     680    free((void *)av);
    677681}
    678682
    679683static
Note: See TracBrowser for help on using the repository browser.