This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] fhandler_pty_master::pty_master_thread: Always check for correct pid
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 24 Jun 2016 21:39:51 -0000
- Subject: [newlib-cygwin] fhandler_pty_master::pty_master_thread: Always check for correct pid
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f4aaa2144173ed4d90c72f14c0da32ebc553a798
commit f4aaa2144173ed4d90c72f14c0da32ebc553a798
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Dec 15 21:49:19 2015 +0100
fhandler_pty_master::pty_master_thread: Always check for correct pid
Diff:
---
winsup/cygwin/fhandler_tty.cc | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index bf912ff..aba469f 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1517,10 +1517,8 @@ fhandler_pty_slave::fixup_after_exec ()
A special case is when the master side of the tty is about to be closed.
The client side is the fhandler_pty_master::close function and it sends
- a PID -1 in that case. On Vista and later a check is performed that the
- request to leave really comes from the master process itself. On earlier
- OSes there's no function to check for the PID of the client process so
- we have to trust the client side.
+ a PID -1 in that case. A check is performed that the request to leave
+ really comes from the master process itself.
Since there's always only one pipe instance, there's a chance that clients
have to wait to connect to the master control pipe. Therefore the client
@@ -1595,10 +1593,8 @@ fhandler_pty_master::pty_master_thread ()
}
if (req.pid == (DWORD) -1) /* Request to finish thread. */
{
- /* Pre-Vista: Just believe in the good of the client process.
- Post-Vista: Check if the requesting process is the master
- process itself. */
- if (pid == (DWORD) -1 || pid == GetCurrentProcessId ())
+ /* Check if the requesting process is the master process itself. */
+ if (pid == GetCurrentProcessId ())
exit = true;
goto reply;
}