diff options
author | Rich Felker <dalias@aerifal.cx> | 2023-02-28 12:18:43 -0500 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2023-02-28 12:18:43 -0500 |
commit | fb7fb5e4bd7ccb8efa691364404efc7804fad90c (patch) | |
tree | a92b7001707d82f2a97151d06cbd7c7e62c7e820 | |
parent | b1dfb734a45d4f74c7a24c5f07d37f7e74451802 (diff) | |
download | musl-fb7fb5e4bd7ccb8efa691364404efc7804fad90c.tar.gz musl-fb7fb5e4bd7ccb8efa691364404efc7804fad90c.tar.xz musl-fb7fb5e4bd7ccb8efa691364404efc7804fad90c.zip |
fix pipe2 silently ignoring unknown flags on old kernels
kernels using the fallback have an inherent close-on-exec race condition and as such support for them is only best-effort anyway. however, ignoring potential new flags is still very bad behavior. instead, fail with EINVAL.
-rw-r--r-- | src/unistd/pipe2.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/unistd/pipe2.c b/src/unistd/pipe2.c index f24f74fb..a096990b 100644 --- a/src/unistd/pipe2.c +++ b/src/unistd/pipe2.c @@ -8,6 +8,7 @@ int pipe2(int fd[2], int flag) if (!flag) return pipe(fd); int ret = __syscall(SYS_pipe2, fd, flag); if (ret != -ENOSYS) return __syscall_ret(ret); + if (flag & ~(O_CLOEXEC|O_NONBLOCK)) return __syscall_ret(-EINVAL); ret = pipe(fd); if (ret) return ret; if (flag & O_CLOEXEC) { |