public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: console: Fix segfault on shared_console_info access. Date: Mon, 24 Feb 2020 18:41:00 -0000 [thread overview] Message-ID: <20200224184139.29269.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=17528b9d2c3147f5de0f604fc2702b2e0010c533 commit 17528b9d2c3147f5de0f604fc2702b2e0010c533 Author: Takashi Yano <takashi.yano@nifty.ne.jp> Date: Tue Feb 25 01:12:16 2020 +0900 Cygwin: console: Fix segfault on shared_console_info access. - Accessing shared_console_info before initialization causes access violation because it is a NULL pointer. The cause of the problem reported in https://cygwin.com/ml/cygwin/2020-02/msg00197.html is this NULL pointer access in request_xterm_mode_output() when it is called from close(). This patch makes sure that shared_console_info is not NULL before calling request_xterm_mode_output(). Diff: --- winsup/cygwin/fhandler_console.cc | 23 +++++++++++------------ winsup/cygwin/release/3.1.5 | 4 ++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 42040a9..328424a 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -1159,18 +1159,17 @@ fhandler_console::close () acquire_output_mutex (INFINITE); - if (shared_console_info && myself->pid == con.owner && - wincap.has_con_24bit_colors () && !con_is_legacy) - request_xterm_mode_output (false); - - /* Restore console mode if this is the last closure. */ - OBJECT_BASIC_INFORMATION obi; - NTSTATUS status; - status = NtQueryObject (get_handle (), ObjectBasicInformation, - &obi, sizeof obi, NULL); - if (NT_SUCCESS (status) && obi.HandleCount == 1) - if (wincap.has_con_24bit_colors ()) - request_xterm_mode_output (false); + if (shared_console_info && wincap.has_con_24bit_colors ()) + { + /* Restore console mode if this is the last closure. */ + OBJECT_BASIC_INFORMATION obi; + NTSTATUS status; + status = NtQueryObject (get_handle (), ObjectBasicInformation, + &obi, sizeof obi, NULL); + if ((NT_SUCCESS (status) && obi.HandleCount == 1) + || myself->pid == con.owner) + request_xterm_mode_output (false); + } release_output_mutex (); diff --git a/winsup/cygwin/release/3.1.5 b/winsup/cygwin/release/3.1.5 index 796fd21..e34fdb8 100644 --- a/winsup/cygwin/release/3.1.5 +++ b/winsup/cygwin/release/3.1.5 @@ -5,3 +5,7 @@ Bug Fixes: Don't move cursor to the right in case of a NUL character in the console output stream, this is not backed by terminfo. Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00162.html + +- Fix a segfault when starting, e.g., mintty from a bash in a console + running xterm emulation. + Addresses: https://cygwin.com/ml/cygwin/2020-02/msg00197.html
reply other threads:[~2020-02-24 18:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200224184139.29269.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).