From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id C02FE3858002; Tue, 15 Aug 2023 23:36:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C02FE3858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692142597; bh=wSbhtty6OhBrPD+yGK6g5jWmW80R8MTPuwDj86Hi2Mk=; h=From:To:Subject:Date:From; b=iqoA8I1a781lFUgwCSZyy0mIvuHZsaM9E/8ZcDveoFJk/JFNlrx4dL1rl5DYB+kyz j1Q+dj8F6tBX9klkDf2GVkr56jL+AyY9dY8bu20nAmDOOBAaR8FJ3o8QSq6uOxy7ZO cZ9BbKa0w4TC0lj9sbY+LJQJzgF3DAp9pICVF8i0= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pty: Add missing pinfo check in transfer_input(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: 46c4a9072436b01f9239bbac2e9a24bc08755026 X-Git-Newrev: 2ee8de782b809c83c4261cc6e7e17bdaf31cff96 Message-Id: <20230815233637.C02FE3858002@sourceware.org> Date: Tue, 15 Aug 2023 23:36:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D2ee8de782b8= 09c83c4261cc6e7e17bdaf31cff96 commit 2ee8de782b809c83c4261cc6e7e17bdaf31cff96 Author: Takashi Yano Date: Mon Aug 14 19:48:12 2023 +0900 Cygwin: pty: Add missing pinfo check in transfer_input(). =20 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. =20 Fixes: 10d083c745dd ("Cygwin: pty: Inherit typeahead data between two i= nput pipes.") Signed-off-by: Takashi Yano 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 db3b77ecf..607333f52 100644 --- a/winsup/cygwin/fhandler/pty.cc +++ b/winsup/cygwin/fhandler/pty.cc @@ -3835,7 +3835,9 @@ fhandler_pty_slave::transfer_input (tty::xfer_dir dir= , HANDLE from, tty *ttyp, to =3D ttyp->to_slave (); =20 pinfo p (ttyp->master_pid); - HANDLE pty_owner =3D OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProces= sId); + HANDLE pty_owner =3D NULL; + if (p) + pty_owner =3D OpenProcess (PROCESS_DUP_HANDLE, FALSE, p->dwProcessId); if (pty_owner) { DuplicateHandle (pty_owner, to, GetCurrentProcess (), &to,