diff options
author | maxim <maxim@FreeBSD.org> | 2002-02-14 15:26:59 +0000 |
---|---|---|
committer | maxim <maxim@FreeBSD.org> | 2002-02-14 15:26:59 +0000 |
commit | c59fce864bad52657c6b15f8ea20cf46fee61cce (patch) | |
tree | 45f7af86510786bbb8774ea2ea23f3b41db75b22 /lib | |
parent | 7e5cf0fb30825cbeae3c1af4113d181c483c2e43 (diff) | |
download | FreeBSD-src-c59fce864bad52657c6b15f8ea20cf46fee61cce.zip FreeBSD-src-c59fce864bad52657c6b15f8ea20cf46fee61cce.tar.gz |
Prevent dup2(2) from closing internal libc_r pipe descriptors.
PR: misc/28947
Reviewed by: jasone, ru
Approved by: jasone, ru
MFC after: 1 week
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc_r/uthread/uthread_dup2.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libc_r/uthread/uthread_dup2.c b/lib/libc_r/uthread/uthread_dup2.c index 6e8195b..af0e32a 100644 --- a/lib/libc_r/uthread/uthread_dup2.c +++ b/lib/libc_r/uthread/uthread_dup2.c @@ -45,7 +45,8 @@ _dup2(int fd, int newfd) int newfd_opened; /* Check if the file descriptor is out of range: */ - if (newfd < 0 || newfd >= _thread_dtablesize) { + if (newfd < 0 || newfd >= _thread_dtablesize || + newfd == _thread_kern_pipe[0] || newfd == _thread_kern_pipe[1]) { /* Return a bad file descriptor error: */ errno = EBADF; ret = -1; |