diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 18:31:44 +0000 |
commit | c23a457e72abe608715ac76f076f47dc42af07a5 (patch) | |
tree | 2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/rustix/src/termios/tty.rs | |
parent | Releasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip |
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/termios/tty.rs')
-rw-r--r-- | vendor/rustix/src/termios/tty.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/vendor/rustix/src/termios/tty.rs b/vendor/rustix/src/termios/tty.rs index 00787a568..56aab9fcf 100644 --- a/vendor/rustix/src/termios/tty.rs +++ b/vendor/rustix/src/termios/tty.rs @@ -2,7 +2,7 @@ use crate::backend; use backend::fd::AsFd; -#[cfg(feature = "procfs")] +#[cfg(all(feature = "alloc", feature = "procfs"))] #[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] use { crate::ffi::CString, crate::io, crate::path::SMALL_PATH_BUFFER_SIZE, alloc::vec::Vec, @@ -33,7 +33,7 @@ pub fn isatty<Fd: AsFd>(fd: Fd) -> bool { /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/ttyname.html /// [Linux]: https://man7.org/linux/man-pages/man3/ttyname.3.html #[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] -#[cfg(feature = "procfs")] +#[cfg(all(feature = "alloc", feature = "procfs"))] #[cfg_attr(doc_cfg, doc(cfg(feature = "procfs")))] #[doc(alias = "ttyname_r")] #[inline] @@ -42,7 +42,7 @@ pub fn ttyname<Fd: AsFd, B: Into<Vec<u8>>>(dirfd: Fd, reuse: B) -> io::Result<CS } #[cfg(not(any(target_os = "fuchsia", target_os = "wasi")))] -#[cfg(feature = "procfs")] +#[cfg(all(feature = "alloc", feature = "procfs"))] #[allow(unsafe_code)] fn _ttyname(dirfd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CString> { buffer.clear(); @@ -54,9 +54,10 @@ fn _ttyname(dirfd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CString> { buffer.reserve(buffer.capacity() + 1); // use `Vec` reallocation strategy to grow capacity exponentially } Ok(len) => { - // SAFETY: assume the backend returns the length of the string + // SAFETY: assume the backend returns the length of the string excluding the + // NUL. unsafe { - buffer.set_len(len); + buffer.set_len(len + 1); } // SAFETY: |