aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorTakashi Yano <takashi.yano@nifty.ne.jp>2024-02-03 00:54:23 +0900
committerTakashi Yano <takashi.yano@nifty.ne.jp>2024-02-03 01:20:13 +0900
commit9bcfd0604533764f3ebfa5015e182f6db7c8922d (patch)
tree19f0c2a1c97b91039c2ee1545364c20909b27f21 /winsup
parentaa73e115242612bf8b5f8670c0c7d398693d1d84 (diff)
downloadnewlib-9bcfd0604533764f3ebfa5015e182f6db7c8922d.zip
newlib-9bcfd0604533764f3ebfa5015e182f6db7c8922d.tar.gz
newlib-9bcfd0604533764f3ebfa5015e182f6db7c8922d.tar.bz2
Cygwin: console: Avoid slipping past disable_master_thread check.
If disable_master_thread flag is set between the code checking that flag not be set and the code acquiring input_mutex, input record is processed once after setting disable_master_thread flag. This patch prevents that. Fixes: d4aacd50e6cf ("Cygwin: console: Add missing input_mutex guard.") Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/fhandler/console.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index 6a42b49..1c8d383 100644
--- a/winsup/cygwin/fhandler/console.cc
+++ b/winsup/cygwin/fhandler/console.cc
@@ -420,6 +420,12 @@ fhandler_console::cons_master_thread (handle_set_t *p, tty *ttyp)
}
WaitForSingleObject (p->input_mutex, mutex_timeout);
+ /* Ensure accessing input recored is not disabled. */
+ if (con.disable_master_thread)
+ {
+ ReleaseMutex (p->input_mutex);
+ continue;
+ }
total_read = 0;
switch (cygwait (p->input_handle, (DWORD) 0))
{
@@ -4545,8 +4551,6 @@ fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
return;
}
const _minor_t unit = cons->get_minor ();
- if (con.disable_master_thread == x)
- return;
cons->acquire_input_mutex (mutex_timeout);
con.disable_master_thread = x;
cons->release_input_mutex ();