public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative
@ 2019-07-24 17:26 Ken Brown
0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2019-07-24 17:26 UTC (permalink / raw)
To: cygwin-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=8a46b8ede22d707aae2dc2e0e53cbad3f26f029f
commit 8a46b8ede22d707aae2dc2e0e53cbad3f26f029f
Author: Ken Brown <kbrown@cornell.edu>
Date: Wed Jul 24 11:29:53 2019 -0400
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.
Diff:
---
winsup/cygwin/fhandler_termios.cc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index 4ce5343..5b0ba56 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -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)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-07-24 17:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 17:26 [newlib-cygwin] Cygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative Ken Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).