Apply patch from pr2536, after testing locally.

Fixes: PR2446 and PR2536

Submitted by: Flemming Jacobsen <fj@tfs.com>

2.2 Candidate.
This commit is contained in:
Warner Losh 1997-01-25 05:27:17 +00:00
parent 17abb434aa
commit 2e42144ea7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=21997

View File

@ -82,7 +82,7 @@ struct arglist {
static char *copynext __P((char *, char *)); static char *copynext __P((char *, char *));
static int fcmp __P((const void *, const void *)); static int fcmp __P((const void *, const void *));
static void formatf __P((struct afile *, int)); static void formatf __P((struct afile *, int));
static void getcmd __P((char *, char *, char *, struct arglist *)); static void getcmd __P((char *, char *, char *, int, struct arglist *));
struct dirent *glob_readdir __P((RST_DIR *dirp)); struct dirent *glob_readdir __P((RST_DIR *dirp));
static int glob_stat __P((const char *, struct stat *)); static int glob_stat __P((const char *, struct stat *));
static void mkentry __P((struct direct *, struct afile *)); static void mkentry __P((struct direct *, struct afile *));
@ -121,7 +121,7 @@ runcmdshell()
volno = 0; volno = 0;
} }
runshell = 1; runshell = 1;
getcmd(curdir, cmd, name, &arglist); getcmd(curdir, cmd, name, sizeof(name), &arglist);
switch (cmd[0]) { switch (cmd[0]) {
/* /*
* Add elements to the extraction list. * Add elements to the extraction list.
@ -300,9 +300,10 @@ runcmdshell()
* eliminate any embedded ".." components. * eliminate any embedded ".." components.
*/ */
static void static void
getcmd(curdir, cmd, name, ap) getcmd(curdir, cmd, name, size, ap)
char *curdir, *cmd, *name; char *curdir, *cmd, *name;
struct arglist *ap; struct arglist *ap;
int size;
{ {
register char *cp; register char *cp;
static char input[BUFSIZ]; static char input[BUFSIZ];
@ -357,7 +358,7 @@ getcmd(curdir, cmd, name, ap)
* If it is an absolute pathname, canonicalize it and return it. * If it is an absolute pathname, canonicalize it and return it.
*/ */
if (rawname[0] == '/') { if (rawname[0] == '/') {
canon(rawname, name, sizeof(name)); canon(rawname, name, size);
} else { } else {
/* /*
* For relative pathnames, prepend the current directory to * For relative pathnames, prepend the current directory to
@ -366,7 +367,7 @@ getcmd(curdir, cmd, name, ap)
(void) strcpy(output, curdir); (void) strcpy(output, curdir);
(void) strcat(output, "/"); (void) strcat(output, "/");
(void) strcat(output, rawname); (void) strcat(output, rawname);
canon(output, name, sizeof(name)); canon(output, name, size);
} }
if (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob) < 0) if (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob) < 0)
fprintf(stderr, "%s: out of memory\n", ap->cmd); fprintf(stderr, "%s: out of memory\n", ap->cmd);