From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22164 invoked from network); 14 Feb 2001 23:33:30 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Feb 2001 23:33:30 -0000 Received: (qmail 5633 invoked by alias); 14 Feb 2001 23:33:25 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13478 Received: (qmail 5622 invoked from network); 14 Feb 2001 23:33:24 -0000 Date: Wed, 14 Feb 2001 18:33:19 -0500 From: Clint Adams To: zsh-workers@sunsite.dk Subject: PATCH: stop null path component segfaults in whence Message-ID: <20010214183319.A11721@dman.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i % 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);