mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-03-04 14:06:13 +08:00
Cygwin: console: Avoid accessing NULL pointer via cygheap->ctty.
- Recent commit "Cygwin: console: Add missing input_mutex guard." has a problem that causes NULL pointer access if cygheap->ctty is NULL. This patch fixes the issue.
This commit is contained in:
parent
28d69dc863
commit
69ec3976d6
@ -2294,7 +2294,7 @@ private:
|
|||||||
static void cleanup_for_non_cygwin_app (handle_set_t *p);
|
static void cleanup_for_non_cygwin_app (handle_set_t *p);
|
||||||
static void set_console_mode_to_native ();
|
static void set_console_mode_to_native ();
|
||||||
bool need_console_handler ();
|
bool need_console_handler ();
|
||||||
static void set_disable_master_thread (bool x);
|
static void set_disable_master_thread (bool x, fhandler_console *cons = NULL);
|
||||||
|
|
||||||
friend tty_min * tty_list::get_cttyp ();
|
friend tty_min * tty_list::get_cttyp ();
|
||||||
};
|
};
|
||||||
|
@ -790,7 +790,7 @@ fhandler_console::setup_for_non_cygwin_app ()
|
|||||||
(get_ttyp ()->getpgid ()== myself->pgid) ? tty::native : tty::restore;
|
(get_ttyp ()->getpgid ()== myself->pgid) ? tty::native : tty::restore;
|
||||||
set_input_mode (conmode, &tc ()->ti, get_handle_set ());
|
set_input_mode (conmode, &tc ()->ti, get_handle_set ());
|
||||||
set_output_mode (conmode, &tc ()->ti, get_handle_set ());
|
set_output_mode (conmode, &tc ()->ti, get_handle_set ());
|
||||||
set_disable_master_thread (true);
|
set_disable_master_thread (true, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -984,7 +984,7 @@ fhandler_console::bg_check (int sig, bool dontsignal)
|
|||||||
if (sig == SIGTTIN)
|
if (sig == SIGTTIN)
|
||||||
{
|
{
|
||||||
set_input_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
|
set_input_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
|
||||||
set_disable_master_thread (false);
|
set_disable_master_thread (false, this);
|
||||||
}
|
}
|
||||||
if (sig == SIGTTOU)
|
if (sig == SIGTTOU)
|
||||||
set_output_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
|
set_output_mode (tty::cygwin, &tc ()->ti, get_handle_set ());
|
||||||
@ -1723,7 +1723,7 @@ fhandler_console::post_open_setup (int fd)
|
|||||||
if (fd == 0)
|
if (fd == 0)
|
||||||
{
|
{
|
||||||
set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
|
set_input_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
|
||||||
set_disable_master_thread (false);
|
set_disable_master_thread (false, this);
|
||||||
}
|
}
|
||||||
else if (fd == 1 || fd == 2)
|
else if (fd == 1 || fd == 2)
|
||||||
set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
|
set_output_mode (tty::cygwin, &get_ttyp ()->ti, &handle_set);
|
||||||
@ -1751,7 +1751,7 @@ fhandler_console::close ()
|
|||||||
/* Cleaning-up console mode for cygwin apps. */
|
/* Cleaning-up console mode for cygwin apps. */
|
||||||
set_output_mode (tty::restore, &get_ttyp ()->ti, &handle_set);
|
set_output_mode (tty::restore, &get_ttyp ()->ti, &handle_set);
|
||||||
set_input_mode (tty::restore, &get_ttyp ()->ti, &handle_set);
|
set_input_mode (tty::restore, &get_ttyp ()->ti, &handle_set);
|
||||||
set_disable_master_thread (true);
|
set_disable_master_thread (true, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3977,7 +3977,7 @@ fhandler_console::set_console_mode_to_native ()
|
|||||||
termios *cons_ti = &cons->tc ()->ti;
|
termios *cons_ti = &cons->tc ()->ti;
|
||||||
set_input_mode (tty::native, cons_ti, cons->get_handle_set ());
|
set_input_mode (tty::native, cons_ti, cons->get_handle_set ());
|
||||||
set_output_mode (tty::native, cons_ti, cons->get_handle_set ());
|
set_output_mode (tty::native, cons_ti, cons->get_handle_set ());
|
||||||
set_disable_master_thread (true);
|
set_disable_master_thread (true, cons);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4357,11 +4357,17 @@ fhandler_console::need_console_handler ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fhandler_console::set_disable_master_thread (bool x)
|
fhandler_console::set_disable_master_thread (bool x, fhandler_console *cons)
|
||||||
{
|
{
|
||||||
if (cygheap->ctty->get_major () != DEV_CONS_MAJOR)
|
if (con.disable_master_thread == x)
|
||||||
return;
|
return;
|
||||||
fhandler_console *cons = (fhandler_console *) cygheap->ctty;
|
if (cons == NULL)
|
||||||
|
{
|
||||||
|
if (cygheap->ctty && cygheap->ctty->get_major () == DEV_CONS_MAJOR)
|
||||||
|
cons = (fhandler_console *) cygheap->ctty;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
cons->acquire_input_mutex (mutex_timeout);
|
cons->acquire_input_mutex (mutex_timeout);
|
||||||
con.disable_master_thread = x;
|
con.disable_master_thread = x;
|
||||||
cons->release_input_mutex ();
|
cons->release_input_mutex ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user