From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7868) id E84DC3858C62; Sat, 22 Oct 2022 05:34:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E84DC3858C62 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666416895; bh=UAa69T4fklvsz5uFnocyMkVG7uSTiRpP/NWZl3FEBP4=; h=From:To:Subject:Date:From; b=Qb0Uw5e0kRXpQqgO9QBWUKUuF1DmUeC3CpzB8iIuRCoaSPassPru2PZEOQ7vXqGPR x/BAMqx4JPNMZgrw+289M6cBJRgWq+96Da4eRHNfAZhQ37k4MFU3y22U2v+p55JlaZ u2s6ShejhXa/XMtn8FMD4dzQ9EyGm9MHGL29igPU= 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_3-branch] Cygwin: pty: Fix 'Bad address' error when running 'cmd.exe /c dir' X-Act-Checkin: newlib-cygwin X-Git-Author: Takashi Yano X-Git-Refname: refs/heads/cygwin-3_3-branch X-Git-Oldrev: 1ca46b22d6edb3d469b51475e8b096d86deaac67 X-Git-Newrev: 08281cf4cca9593adcc3d30184322dc60fa1cd61 Message-Id: <20221022053455.E84DC3858C62@sourceware.org> Date: Sat, 22 Oct 2022 05:34:55 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D08281cf4cca= 9593adcc3d30184322dc60fa1cd61 commit 08281cf4cca9593adcc3d30184322dc60fa1cd61 Author: Takashi Yano Date: Sat Oct 22 14:05:40 2022 +0900 Cygwin: pty: Fix 'Bad address' error when running 'cmd.exe /c dir' =20 - If the command executed is 'cmd.exe /c [...]', runpath in spawn.cc will be NULL. In this case, is_console_app(runpath) check causes access violation. This case also the command executed is obviously console app., therefore, treat it as console app to fix this issue. =20 Addresses: https://github.com/msys2/msys2-runtime/issues/108 Diff: --- winsup/cygwin/spawn.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index d9d771651..972533554 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -198,6 +198,8 @@ handle (int fd, bool writing) static bool is_console_app (WCHAR *filename) { + if (filename =3D=3D NULL) + return true; /* The command executed is command.com or cmd.exe. */ HANDLE h; const int id_offset =3D 92; h =3D CreateFileW (filename, GENERIC_READ, FILE_SHARE_READ,