Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible Bug
On Mon, 31 Aug 2015 22:53:04 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author