소스 검색

fix fd leak race (missing O_CLOEXEC) in fchmodat

Rich Felker 10 년 전
부모
커밋
2736eb6caa
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/stat/fchmodat.c

+ 1 - 1
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);