From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4517 invoked by alias); 1 Sep 2015 20:51:18 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36378 Received: (qmail 19734 invoked from network); 1 Sep 2015 20:51:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-Originating-IP: [80.3.228.158] X-Spam: 0 X-Authority: v=2.1 cv=AJvf2gUA c=1 sm=1 tr=0 a=P+FLVI8RzFchTbbqTxIDRw==:117 a=P+FLVI8RzFchTbbqTxIDRw==:17 a=NLZqzBF-AAAA:8 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=PzBv_w8m1kcas2PbsQgA:9 a=CjuIK1q_8ugA:10 Date: Tue, 1 Sep 2015 21:51:06 +0100 From: Peter Stephenson To: Bart Schaefer , "zsh-workers@zsh.org " Cc: Brian Millar Subject: Re: Possible Bug Message-ID: <20150901215106.2dd1eff6@ntlworld.com> In-Reply-To: <150831225304.ZM599@torch.brasslantern.com> References: <150831225304.ZM599@torch.brasslantern.com> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 31 Aug 2015 22:53:04 -0700 Bart Schaefer wrote: > Confirmed this. Autoloading calls access(..., R_OK) but does not stat() > for plain-file-ness before attempting to open() and load into memory. The tests we usually use for this kind of thing look like this. This means we'll skip the directory silently and find a regular file within another directory if there is one, and only report an error if there isn't --- I presume that's correct. pws diff --git a/Src/exec.c b/Src/exec.c index 45f1c66..109a04a 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -5392,7 +5392,9 @@ getfpfunc(char *s, int *ksh, char **fname) } unmetafy(buf, NULL); if (!access(buf, R_OK) && (fd = open(buf, O_RDONLY | O_NOCTTY)) != -1) { - if ((len = lseek(fd, 0, 2)) != -1) { + struct stat st; + if (!fstat(fd, &st) && S_ISREG(st.st_mode) && + (len = lseek(fd, 0, 2)) != -1) { d = (char *) zalloc(len + 1); lseek(fd, 0, 0); if ((rlen = read(fd, d, len)) >= 0) {