summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/uthread
diff options
context:
space:
mode:
authorfgsch <fgsch@openbsd.org>2002-02-19 01:10:24 +0000
committerfgsch <fgsch@openbsd.org>2002-02-19 01:10:24 +0000
commitf561007a160f1cc32eda3505a432cd19208a7972 (patch)
treecb388dc96a21c5718aa3821e59da563246fcd969 /lib/libpthread/uthread
parentfix this by now; .Rv prolly has to be removed. (diff)
downloadwireguard-openbsd-f561007a160f1cc32eda3505a432cd19208a7972.tar.xz
wireguard-openbsd-f561007a160f1cc32eda3505a432cd19208a7972.zip
From FreeBSD:
Prevent dup2(2) from closing internal libc_r pipe descriptors.
Diffstat (limited to 'lib/libpthread/uthread')
-rw-r--r--lib/libpthread/uthread/uthread_dup2.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libpthread/uthread/uthread_dup2.c b/lib/libpthread/uthread/uthread_dup2.c
index 2dfd9d8c361..5809c4c66b7 100644
--- a/lib/libpthread/uthread/uthread_dup2.c
+++ b/lib/libpthread/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;