From 521d330d048af5df80b2ffdb268141f907de4844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Tue, 8 Jun 2021 18:04:35 +0200 Subject: [PATCH] [CMD] Use GetFullPathName instead of copying buffers when resolving executable names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This properly strips spaces & dots at the end of the file. Fixes the infinite loop with CreateProcess calling cmd over and over with e.g. 'cmd /c "some_script.bat "' Uncovered by recent ShellExecuteEx tests Dedicated to Katayama for the trigger & Hermès for the tests --- base/shell/cmd/where.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/shell/cmd/where.c b/base/shell/cmd/where.c index 0ba4c08c5ec..4030a877a73 100644 --- a/base/shell/cmd/where.c +++ b/base/shell/cmd/where.c @@ -106,7 +106,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pPathExt, if (IsExistingFile (szPathBuffer)) { TRACE ("Found: \'%s\'\n", debugstr_aw(szPathBuffer)); - _tcscpy (pFullName, szPathBuffer); + GetFullPathName(szPathBuffer, MAX_PATH, pFullName, NULL); return TRUE; } @@ -130,7 +130,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pPathExt, if (IsExistingFile (szPathBuffer)) { TRACE ("Found: \'%s\'\n", debugstr_aw(szPathBuffer)); - _tcscpy (pFullName, szPathBuffer); + GetFullPathName(szPathBuffer, MAX_PATH, pFullName, NULL); return TRUE; } }