aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0027-fix-fd-leak-race-missing-O_CLOEXEC-in-fchmodat.patch
blob: 0a1f608dbc521f295bcd6c0d1ccd7f518ca4e312 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
From 2736eb6caa70bb6e909d7d8ebbe145c2071435e0 Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 4 Feb 2015 22:50:40 -0500
Subject: [PATCH] fix fd leak race (missing O_CLOEXEC) in fchmodat

---
 src/stat/fchmodat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/stat/fchmodat.c b/src/stat/fchmodat.c
index afa6d44..a894cb6 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);
-- 
2.3.3