public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin/cygwin-3_4-branch] Cygwin: pty: Add missing pinfo check in transfer_input().
@ 2023-08-15 23:36 Takashi Yano
  0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2023-08-15 23:36 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=efba30dd1d4cf3db6df7f7bc7ee13775c577f1a1

commit efba30dd1d4cf3db6df7f7bc7ee13775c577f1a1
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Mon Aug 14 19:48:12 2023 +0900

    Cygwin: pty: Add missing pinfo check in transfer_input().
    
    The commit 10d083c745dd has a bug that lacks a check for pinfo pointer
    value for master_pid. This causes segmentation fault if the process
    whose pid is master_pid no longer exists. This patch fixes the issue.
    
    Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two input pipes.")
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 winsup/cygwin/fhandler/pty.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index e9d9b351d..df37d9189 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -3886,7 +3886,9 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir, HANDLE from, tty *ttyp,
     to = ttyp->to_slave ();
 
   pinfo p (ttyp->master_pid);
-  HANDLE pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId);
+  HANDLE pty_owner = NULL;
+  if (p)
+    pty_owner = OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId);
   if (pty_owner)
     {
       DuplicateHandle (pty_owner, to, GetCurrentProcess (), &to,

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-08-15 23:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-15 23:36 [newlib-cygwin/cygwin-3_4-branch] Cygwin: pty: Add missing pinfo check in transfer_input() Takashi Yano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).