summaryrefslogtreecommitdiff
path: root/Src/parse.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.w.stephenson@ntlworld.com>2013-07-20 23:23:18 +0100
committerPeter Stephenson <p.w.stephenson@ntlworld.com>2013-07-20 23:23:18 +0100
commit39ab9952e8255cb99e9c0abcc8bbec43158a55d7 (patch)
tree66f73559ea86998c8ac97684029aca20308c5721 /Src/parse.c
parent9a192dddd277b2bf94785c9d13f3bfeb41715cf2 (diff)
downloadzsh-39ab9952e8255cb99e9c0abcc8bbec43158a55d7.tar.gz
zsh-39ab9952e8255cb99e9c0abcc8bbec43158a55d7.zip
31545: Use of FD_CLOEXEC to remove possibility of fd reuse.
File descriptors of mmap'd dump files are closed if and only if an exec is performed.
Diffstat (limited to 'Src/parse.c')
-rw-r--r--Src/parse.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Src/parse.c b/Src/parse.c
index 753080d70..b670925de 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3171,6 +3171,9 @@ load_dump_file(char *dump, struct stat *sbuf, int other, int len)
d->dev = sbuf->st_dev;
d->ino = sbuf->st_ino;
d->fd = fd;
+#ifdef FD_CLOEXEC
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
d->map = addr + (other ? (len - off) / sizeof(wordcode) : 0);
d->addr = addr;
d->len = len;
@@ -3439,6 +3442,7 @@ decrdumpcount(FuncDump f)
}
}
+#ifndef FD_CLOEXEC
/**/
mod_export void
closedumps(void)
@@ -3448,6 +3452,7 @@ closedumps(void)
for (p = dumps; p; p = p->next)
zclose(p->fd);
}
+#endif
#else
@@ -3461,11 +3466,13 @@ decrdumpcount(FuncDump f)
{
}
+#ifndef FD_CLOEXEC
/**/
mod_export void
closedumps(void)
{
}
+#endif
#endif