Commit 8a46b8ed authored by Ken Brown's avatar Ken Brown

Cygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative

Return -1 with EINVAL if pgid < 0.

Previously tcsetpgrp() would blindly go ahead and set the pgid of the
controlling terminal to a negative value, causing later calls to
various functions to fail.

For example, gdb has code like the following:

  tcsetpgrp (0, getpgid (inf->pid));

If getpgid (inf->pid) fails (returns -1), then this code would set the
pgid of fd 0 to -1, so that some later calls to getpgid() would also
return -1.  This caused the problem reported here:

  https://cygwin.com/ml/cygwin/2019-07/msg00166.html.
parent 280b21d3
......@@ -69,6 +69,11 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
set_errno (EPERM);
return -1;
}
else if (pgid < 0)
{
set_errno (EINVAL);
return -1;
}
int res;
while (1)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment