public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: console: Avoid slipping past disable_master_thread check.
@ 2024-02-02 16:21 Takashi Yano
  0 siblings, 0 replies; only message in thread
From: Takashi Yano @ 2024-02-02 16:21 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c2be9bf5eb687389e4d0385839f2f5b78bb820be

commit c2be9bf5eb687389e4d0385839f2f5b78bb820be
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Sat Feb 3 00:54:23 2024 +0900

    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>

Diff:
---
 winsup/cygwin/fhandler/console.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/console.cc
index 6a42b4949..1c8d383cd 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 ();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-02 16:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02 16:21 [newlib-cygwin] Cygwin: console: Avoid slipping past disable_master_thread check Takashi Yano

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).