From c59fce864bad52657c6b15f8ea20cf46fee61cce Mon Sep 17 00:00:00 2001 From: maxim Date: Thu, 14 Feb 2002 15:26:59 +0000 Subject: 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 --- lib/libc_r/uthread/uthread_dup2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') 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; -- cgit v1.1