From: Rich Felker Date: Thu, 5 Feb 2015 03:50:40 +0000 (-0500) Subject: fix fd leak race (missing O_CLOEXEC) in fchmodat X-Git-Tag: v1.1.7~67 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2736eb6caa70bb6e909d7d8ebbe145c2071435e0;p=oweals%2Fmusl.git fix fd leak race (missing O_CLOEXEC) in fchmodat --- diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c index afa6d44b..a894cb69 100644 --- a/src/stat/fchmodat.c +++ b/src/stat/fchmodat.c @@ -21,7 +21,7 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) if (S_ISLNK(st.st_mode)) return __syscall_ret(-EOPNOTSUPP); - if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY)) < 0) { + if ((fd2 = __syscall(SYS_openat, fd, path, O_RDONLY|O_PATH|O_NOFOLLOW|O_NOCTTY|O_CLOEXEC)) < 0) { if (fd2 == -ELOOP) return __syscall_ret(-EOPNOTSUPP); return __syscall_ret(fd2);