Cygwin: pty: Fix a bug in tty_min::segpgid().

- 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.
This commit is contained in:
Takashi Yano 2022-02-13 05:12:18 +09:00
parent c4704c7c20
commit bed1add783
1 changed files with 2 additions and 1 deletions

View File

@ -309,7 +309,8 @@ tty_min::setpgid (int pid)
fhandler_pty_slave *ptys = NULL;
cygheap_fdenum cfd (false);
while (cfd.next () >= 0 && ptys == NULL)
if (cfd->get_device () == getntty ())
if (cfd->get_device () == getntty ()
&& cfd->get_major () == DEV_PTYS_MAJOR)
ptys = (fhandler_pty_slave *) (fhandler_base *) cfd;
if (ptys)