From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id 52CA93858016; Sun, 13 Feb 2022 15:18:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52CA93858016 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_3-branch] Cygwin: pty: Fix a bug in tty_min::segpgid(). X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_3-branch X-Git-Oldrev: 77247c077b3334dc987d3f7269d42b75807abcf3 X-Git-Newrev: 394c380746bbc6b371aae652469a6fe770dc45d9 Message-Id: <20220213151810.52CA93858016@sourceware.org> Date: Sun, 13 Feb 2022 15:18:10 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Feb 2022 15:18:10 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D394c380746b= bc6b371aae652469a6fe770dc45d9 commit 394c380746bbc6b371aae652469a6fe770dc45d9 Author: Takashi Yano Date: Sun Feb 13 05:12:18 2022 +0900 Cygwin: pty: Fix a bug in tty_min::segpgid(). =20 - In tty_min::setpgid(), a pointer to fhandler instance is casted to fhandler_pty_slave and accessed even if terminal is not a pty slave. This patch fixes the issue. Diff: --- winsup/cygwin/tty.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index da75b8dd2..c0015aceb 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -309,7 +309,8 @@ tty_min::setpgid (int pid) fhandler_pty_slave *ptys =3D NULL; cygheap_fdenum cfd (false); while (cfd.next () >=3D 0 && ptys =3D=3D NULL) - if (cfd->get_device () =3D=3D getntty ()) + if (cfd->get_device () =3D=3D getntty () + && cfd->get_major () =3D=3D DEV_PTYS_MAJOR) ptys =3D (fhandler_pty_slave *) (fhandler_base *) cfd; =20 if (ptys)