From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id A9F623858002; Tue, 15 Aug 2023 23:36:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A9F623858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1692142577; bh=wGu8d6jfP3GkcwwnX79LFxvDCAPu9HUDtDDiDohnZ7Y=; h=From:To:Subject:Date:From; b=tHplsxarEWIIQLMF9cJqJ2Yzg+Nx4Dzor7BwXquKSa/8mSWoTxcn45ck8vi5aIGVO ANNMmti8DNj/PiwI0BF/QjIhWlmDjA/xfNRpNgYdufwG+LpGPNm3G9gPv2L8tMQ7lu d8DqV5D8i72wdZb6kZ94Eycl7KCQR2+L127qt+nU= 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-3_4-branch] Cygwin: pty: Add missing pinfo check in transfer_input(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_4-branch X-Git-Oldrev: d2354ee412391111f3cb7408a10d9a6af72fe048 X-Git-Newrev: efba30dd1d4cf3db6df7f7bc7ee13775c577f1a1 Message-Id: <20230815233617.A9F623858002@sourceware.org> Date: Tue, 15 Aug 2023 23:36:17 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Defba30dd1d4= cf3db6df7f7bc7ee13775c577f1a1 commit efba30dd1d4cf3db6df7f7bc7ee13775c577f1a1 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 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 =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,