From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id EA8F23858D33; Fri, 2 Feb 2024 05:31:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA8F23858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1706851912; bh=eOxrrxyBHY8ov/9IX4zpncgrjMPVyF4cSON8Ldbf4zU=; h=From:To:Subject:Date:From; b=o1FHR2m6Js59yqaNIrr/HsOWnlx62ajD421jZ/I0hvNMFmf0nUJ5xtOzzSg2C4Ldn 3HZaOqgotj+h2oSNmlGdeUMsAjijJXTgvHAAvRvjH/zhYGnWOYPjN7x0LAZu6BjGrR 54EXQ/ZV3/zxaKPs7H7+JbzBTZZVsT0biRV8Eaao= 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-3_5-branch] Cygwin: console: Fix exit code for non-cygwin process. X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_5-branch X-Git-Oldrev: 23737b04cc52a0473d524661a51779224c0d7b8b X-Git-Newrev: aa73e115242612bf8b5f8670c0c7d398693d1d84 Message-Id: <20240202053152.EA8F23858D33@sourceware.org> Date: Fri, 2 Feb 2024 05:31:52 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3Daa73e115242= 612bf8b5f8670c0c7d398693d1d84 commit aa73e115242612bf8b5f8670c0c7d398693d1d84 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 ();