summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2000-09-19 16:47:38 +0000
committerClint Adams <clint@users.sourceforge.net>2000-09-19 16:47:38 +0000
commit9f012ce7c91cf517242bd2d26e6d97dca61f791c (patch)
treea673824bf8e605467ecc6a09057c34eccc5e916b
parent946085efa5b9b949664ab94fcda302914936a1c5 (diff)
downloadzsh-9f012ce7c91cf517242bd2d26e6d97dca61f791c.tar.gz
zsh-9f012ce7c91cf517242bd2d26e6d97dca61f791c.tar.xz
zsh-9f012ce7c91cf517242bd2d26e6d97dca61f791c.zip
12847: dynamically allocate buf and z in bin_whence()
-rw-r--r--ChangeLog3
-rw-r--r--Src/builtin.c14
2 files changed, 9 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 31a31c6f6..c8f41ce75 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2000-09-19  Clint Adams  <schizo@debian.org>
 
+	* 12847: Src/builtin.c: dynamically allocate z and buf in
+	bin_whence().
+
 	* 12846: Src/.distfiles, Src/mem.c, Src/string.c, Src/utils.c,
 	Src/zsh.mdd: Move dupstring(), ztrdup(), tricat(), zhtricat(),
 	dyncat(), dupstrpfx(), ztrduppfx(), and appstr() to string.c.
diff --git a/Src/builtin.c b/Src/builtin.c
index 6fa8da6e3..efbbd20d9 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2390,17 +2390,14 @@ bin_whence(char *nam, char **argv, char *ops, int func)
 	/* Option -a is to search the entire path, *
 	 * rather than just looking for one match. */
 	if (all) {
-	    char **pp, buf[PATH_MAX], *z;
+	    char **pp, *buf, *z;
 
+	    pushheap();
 	    for (pp = path; *pp; pp++) {
-		z = buf;
 		if (**pp) {
-		    strucpy(&z, *pp);
-		    *z++ = '/';
-		}
-		if ((z - buf) + strlen(*argv) >= PATH_MAX)
-		    continue;
-		strcpy(z, *argv);
+		    z = dyncat(*pp, "/");
+		} else z = NULL;
+		buf = dyncat(z, *argv);
 		if (iscom(buf)) {
 		    if (wd) {
 			printf("%s: command\n", *argv);
@@ -2420,6 +2417,7 @@ bin_whence(char *nam, char **argv, char *ops, int func)
 		puts(wd ? ": none" : " not found");
 		returnval = 1;
 	    }
+	    popheap();
 	} else if ((cnam = findcmd(*argv, 1))) {
 	    /* Found external command. */
 	    if (wd) {