diff options
author | Todd C. Miller <Todd.Miller@sudo.ws> | 2023-04-18 13:52:26 -0600 |
---|---|---|
committer | Todd C. Miller <Todd.Miller@sudo.ws> | 2023-04-18 13:52:26 -0600 |
commit | b7dc12f149082506ab125eb49bfc1e3a55608c2f (patch) | |
tree | 554cc6dbd48baafa7a5e2e78447734a3f997fea8 /src/selinux.c | |
parent | d48a3fdeef949d44c817035a85cb4b540b3b5fc4 (diff) | |
download | sudo-b7dc12f149082506ab125eb49bfc1e3a55608c2f.tar.gz |
Avoid calling isatty()/ttyname() on std{in,out,err} if not a char dev.
The user controls these fds so we should avoid calling ioctl(2) on
them unless they correspond to actual character device files.
Diffstat (limited to 'src/selinux.c')
-rw-r--r-- | src/selinux.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/selinux.c b/src/selinux.c index 50455f4d0..153bd58d4 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -273,7 +273,7 @@ selinux_relabel_tty(const char *ttyn, int ptyfd) (void)fcntl(se_state.ttyfd, F_SETFL, fcntl(se_state.ttyfd, F_GETFL, 0) & ~O_NONBLOCK); for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) { - if (isatty(fd) && dup2(se_state.ttyfd, fd) == -1) { + if (sudo_isatty(fd, &sb) && dup2(se_state.ttyfd, fd) == -1) { sudo_warn("dup2"); goto bad; } |