diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2022-09-06 08:36:09 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-09-06 08:36:09 +0900 |
| commit | c6f6b1821d29a97b76310ab2120c416aabe2f67a (patch) | |
| tree | 11afb7ed3be41d4e0f15b49104b8ee5ac2cce68c /library | |
| parent | c3faa2250c67ac040fba77828b7e042940412110 (diff) | |
| parent | 0e0756cf0d1b55f3de4815088276a584e2c31f14 (diff) | |
| download | rust-c6f6b1821d29a97b76310ab2120c416aabe2f67a.tar.gz rust-c6f6b1821d29a97b76310ab2120c416aabe2f67a.zip | |
Rollup merge of #101426 - beetrees:dup-no-stdio, r=thomcc
Don't duplicate file descriptors into stdio fds Ensures that file descriptors are never duplicated into the stdio fds even if a stdio fd has been closed.
Diffstat (limited to 'library')
| -rw-r--r-- | library/std/src/os/fd/owned.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/std/src/os/fd/owned.rs b/library/std/src/os/fd/owned.rs index a463bc41db7..71e33fb9ed8 100644 --- a/library/std/src/os/fd/owned.rs +++ b/library/std/src/os/fd/owned.rs @@ -104,7 +104,8 @@ impl BorrowedFd<'_> { #[cfg(target_os = "espidf")] let cmd = libc::F_DUPFD; - let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 0) })?; + // Avoid using file descriptors below 3 as they are used for stdio + let fd = cvt(unsafe { libc::fcntl(self.as_raw_fd(), cmd, 3) })?; Ok(unsafe { OwnedFd::from_raw_fd(fd) }) } |
