* lseek() on directories, again
@ 2015-09-20 5:13 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2015-09-20 5:13 UTC (permalink / raw)
To: zsh-workers
Here's another case like the one in exec.c (reported in 36350) where we
should not be calling lseek() on a directory opened for reading.
diff --git a/Src/parse.c b/Src/parse.c
index 7c2d202..a26df6f 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3227,6 +3227,8 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
noaliases = ali;
for (hlen = FD_PRELEN, tlen = 0; *files; files++) {
+ struct stat st;
+
if (!strcmp(*files, "-k")) {
flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_KSHLOAD;
continue;
@@ -3235,6 +3237,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
continue;
}
if ((fd = open(*files, O_RDONLY)) < 0 ||
+ fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) ||
(flen = lseek(fd, 0, 2)) == -1) {
if (fd >= 0)
close(fd);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-20 5:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-20 5:13 lseek() on directories, again Bart Schaefer
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).