diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-02-19 01:10:25 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2002-02-19 01:10:25 +0000 |
commit | 99f0cfd0a7b4d70d7504fce7cb365b0e889a4bb7 (patch) | |
tree | 4eed25597b5b4205525126c49393bbdadaae1720 /lib/libc_r/uthread | |
parent | 800406cbe6c4c1de26f8a3e7511fb34e075c9db6 (diff) |
From FreeBSD:
Prevent dup2(2) from closing internal libc_r pipe descriptors.
Diffstat (limited to 'lib/libc_r/uthread')
-rw-r--r-- | lib/libc_r/uthread/uthread_dup2.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc_r/uthread/uthread_dup2.c b/lib/libc_r/uthread/uthread_dup2.c index 2dfd9d8c361..5809c4c66b7 100644 --- a/lib/libc_r/uthread/uthread_dup2.c +++ b/lib/libc_r/uthread/uthread_dup2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_dup2.c,v 1.4 1999/11/25 07:01:33 d Exp $ */ +/* $OpenBSD: uthread_dup2.c,v 1.5 2002/02/19 01:10:24 fgsch Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -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; |