1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-08 12:01:21 +02:00

36566: check for regular file before lseek()

This commit is contained in:
Barton E. Schaefer 2015-09-19 23:05:44 -07:00
parent 4375d7b905
commit e61717b606
2 changed files with 5 additions and 0 deletions

View file

@ -1,5 +1,7 @@
2015-09-19 Barton E. Schaefer <schaefer@zsh.org> 2015-09-19 Barton E. Schaefer <schaefer@zsh.org>
* 36566: Src/parse.c: check for regular file before lseek()
* 36562: Src/utils.c: sanitize $PWD on import, per POSIX * 36562: Src/utils.c: sanitize $PWD on import, per POSIX
2015-09-19 Peter Stephenson <p.w.stephenson@ntlworld.com> 2015-09-19 Peter Stephenson <p.w.stephenson@ntlworld.com>

View file

@ -3227,6 +3227,8 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
noaliases = ali; noaliases = ali;
for (hlen = FD_PRELEN, tlen = 0; *files; files++) { for (hlen = FD_PRELEN, tlen = 0; *files; files++) {
struct stat st;
if (!strcmp(*files, "-k")) { if (!strcmp(*files, "-k")) {
flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_KSHLOAD; flags = (flags & ~(FDHF_KSHLOAD | FDHF_ZSHLOAD)) | FDHF_KSHLOAD;
continue; continue;
@ -3235,6 +3237,7 @@ build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
continue; continue;
} }
if ((fd = open(*files, O_RDONLY)) < 0 || if ((fd = open(*files, O_RDONLY)) < 0 ||
fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) ||
(flen = lseek(fd, 0, 2)) == -1) { (flen = lseek(fd, 0, 2)) == -1) {
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);