[PATCH 0/1] MR5183: cmd: Fix calling .bat failure, when filename with inbuilt keyword.
For example, calling start.bat. Signed-off-by: Haidong Yu <yuhaidong(a)uniontech.com> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5183
From: Haidong Yu <yuhaidong(a)uniontech.com> For example, calling start.bat. Signed-off-by: Haidong Yu <yuhaidong(a)uniontech.com> --- programs/cmd/wcmdmain.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 1867c5afb92..99bdcfe12f7 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -1325,9 +1325,17 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, while (IsCharAlphaNumericW(whichcmd[count])) { count++; } - for (i=0; i<=WCMD_EXIT; i++) { - if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, - whichcmd, count, inbuilt[i], -1) == CSTR_EQUAL) break; + if (wcsnicmp(&whichcmd[count], L".bat", 4)) + { + for (i=0; i<=WCMD_EXIT; i++) { + if (CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, + whichcmd, count, inbuilt[i], -1) == CSTR_EQUAL) break; + } + } + else + { + i=WCMD_CALL; + count = 0; } cmd_index = i; parms_start = WCMD_skip_leading_spaces (&whichcmd[count]); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5183
it seems to me that the `while (IsCharAlphaNumericA(whichcmd[count]))` loop (above your change) is the culprit didn't test it, but it's very likely that `for_` `for+` `for.bat` `for.exe` (to name a few) should not be interpreted as `for` command you should add tests to confirm (or infirm) this assumption and fix the loop accordingly I wouldn't be surprised if something like (didn't think off all the possible characters) ``` while (strchr(" \t()<>|,=;", whichcmd[count]) == NULL) ``` would be more suited -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5183#note_62906
This merge request was closed by Haidong Yu. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5183
I made some modifications and added test cases. Please see my latest merge requests.thk -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5183#note_63037
participants (3)
-
eric pouech (@epo) -
Haidong Yu -
Haidong Yu (@yhd986)