Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: stop null path component segfaults in whence



% PATH=/usr/bin::/bin
% type -a type
will result in a segfault if your strlen() doesn't cope with NULL
(and I can't seem to find one that actually does)

This copes better, though I don't see much point in having an empty
element in the path.

Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.41
diff -u -r1.41 builtin.c
--- Src/builtin.c	2001/01/26 12:47:37	1.41
+++ Src/builtin.c	2001/02/14 23:29:28
@@ -2468,14 +2468,14 @@
 	/* Option -a is to search the entire path, *
 	 * rather than just looking for one match. */
 	if (all) {
-	    char **pp, *buf, *z;
+	    char **pp, *buf;
 
 	    pushheap();
 	    for (pp = path; *pp; pp++) {
 		if (**pp) {
-		    z = dyncat(*pp, "/");
-		} else z = NULL;
-		buf = dyncat(z, *argv);
+		    buf = zhtricat(*pp, "/", *argv);
+		} else buf = ztrdup(*argv);
+
 		if (iscom(buf)) {
 		    if (wd) {
 			printf("%s: command\n", *argv);



Messages sorted by: Reverse Date, Date, Thread, Author