zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Bart Schaefer <schaefer@brasslantern.com>,
	"zsh-workers@zsh.org " <zsh-workers@zsh.org>
Cc: Brian Millar <D00144121@student.dkit.ie>
Subject: Re: Possible Bug
Date: Tue, 1 Sep 2015 21:51:06 +0100	[thread overview]
Message-ID: <20150901215106.2dd1eff6@ntlworld.com> (raw)
In-Reply-To: <150831225304.ZM599@torch.brasslantern.com>

On Mon, 31 Aug 2015 22:53:04 -0700
Bart Schaefer <schaefer@brasslantern.com> 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) {


      parent reply	other threads:[~2015-09-01 20:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-31 21:30 Brian Millar
2015-09-01  5:53 ` Bart Schaefer
2015-09-01 12:02   ` Brian Millar
2015-09-01 20:51   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150901215106.2dd1eff6@ntlworld.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=D00144121@student.dkit.ie \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).