From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id C13C33858D33; Fri, 2 Feb 2024 05:31:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C13C33858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706851877; bh=6hbT5+BRezGwlNmtBxeaobkL20x/iJwENW37H3EYBiI=; h=From:To:Subject:Date:From; b=vjoWH3b7d8BKD9QaEu50hY02smU2kyZmD+NQK1X97A1JBq0eDNu17ksNeR6CqmTB9 mBRblAMb1mZ4JnvjgrXcIQqoMCj24yS/6GagOxJcrsCQ7NlUSm+MoZmlme8mX9XEWQ s4Lz5TtFblZ6Cz52DQgOkMOEjH6qLyuAio+qS3sY= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Takashi Yano To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: console: Fix exit code for non-cygwin process. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/master X-Git-Oldrev: c414e1b97252789d2ab46c1b8fbe502a9ffca8b8 X-Git-Newrev: 084f848ab9a51d0125491a6f2a7a741f9df73218 Message-Id: <20240202053117.C13C33858D33@sourceware.org> Date: Fri, 2 Feb 2024 05:31:17 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D084f848ab9a= 51d0125491a6f2a7a741f9df73218 commit 084f848ab9a51d0125491a6f2a7a741f9df73218 Author: Takashi Yano Date: Fri Feb 2 13:59:19 2024 +0900 Cygwin: console: Fix exit code for non-cygwin process. =20 If non-cygwin process is executed in console, the exit code is not set correctly. This is because the stub process for non-cygwin app crashes in fhandler_console::set_disable_master_thread() due to NULL pointer dereference. This bug was introduced by the commit: 3721a756b0d8 ("Cygwin: console: Make the console accessible from other terminals."), that the pointer cons is accessed before fixing when it is NULL. This patch fixes the issue. =20 Fixes: 3721a756b0d8 ("Cygwin: console: Make the console accessible from= other terminals.") Reported-by: Johannes Schindelin Signed-off-by: Takashi Yano Diff: --- winsup/cygwin/fhandler/console.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/fhandler/console.cc b/winsup/cygwin/fhandler/con= sole.cc index b924a6bf3..6a42b4949 100644 --- a/winsup/cygwin/fhandler/console.cc +++ b/winsup/cygwin/fhandler/console.cc @@ -4537,9 +4537,6 @@ fhandler_console::need_console_handler () void fhandler_console::set_disable_master_thread (bool x, fhandler_console *con= s) { - const _minor_t unit =3D cons->get_minor (); - if (con.disable_master_thread =3D=3D x) - return; if (cons =3D=3D NULL) { if (cygheap->ctty && cygheap->ctty->get_major () =3D=3D DEV_CONS_MAJ= OR) @@ -4547,6 +4544,9 @@ fhandler_console::set_disable_master_thread (bool x, = fhandler_console *cons) else return; } + const _minor_t unit =3D cons->get_minor (); + if (con.disable_master_thread =3D=3D x) + return; cons->acquire_input_mutex (mutex_timeout); con.disable_master_thread =3D x; cons->release_input_mutex ();