[CMD] Use GetFullPathName instead of copying buffers when resolving executable names

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
This commit is contained in:
Jérôme Gardou 2021-06-08 18:04:35 +02:00 committed by Jérôme Gardou
parent 94d9e9c2a8
commit 521d330d04

View file

@ -106,7 +106,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pPathExt,
if (IsExistingFile (szPathBuffer)) if (IsExistingFile (szPathBuffer))
{ {
TRACE ("Found: \'%s\'\n", debugstr_aw(szPathBuffer)); TRACE ("Found: \'%s\'\n", debugstr_aw(szPathBuffer));
_tcscpy (pFullName, szPathBuffer); GetFullPathName(szPathBuffer, MAX_PATH, pFullName, NULL);
return TRUE; return TRUE;
} }
@ -130,7 +130,7 @@ SearchForExecutableSingle (LPCTSTR pFileName, LPTSTR pFullName, LPTSTR pPathExt,
if (IsExistingFile (szPathBuffer)) if (IsExistingFile (szPathBuffer))
{ {
TRACE ("Found: \'%s\'\n", debugstr_aw(szPathBuffer)); TRACE ("Found: \'%s\'\n", debugstr_aw(szPathBuffer));
_tcscpy (pFullName, szPathBuffer); GetFullPathName(szPathBuffer, MAX_PATH, pFullName, NULL);
return TRUE; return TRUE;
} }
} }