瀏覽代碼

in faccessat slow path, add close-on-exec to pipe fds

as usual, this is needed to avoid fd leaks. as a better solution, the
use of fds could possibly be replaced with mmap and a futex.
Rich Felker 11 年之前
父節點
當前提交
d5bd7dd5d2
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/unistd/faccessat.c

+ 1 - 1
src/unistd/faccessat.c

@@ -34,7 +34,7 @@ int faccessat(int fd, const char *filename, int amode, int flag)
 	sigset_t set;
 	int ret, p[2];
 
-	if (pipe(p)) return __syscall_ret(-EBUSY);
+	if (pipe2(p, O_CLOEXEC)) return __syscall_ret(-EBUSY);
 	struct ctx c = { .fd = fd, .filename = filename, .amode = amode, .p = p[1] };
 
 	__block_all_sigs(&set);