For example, calling start.bat.
Signed-off-by: Haidong Yu yuhaidong@uniontech.com
From: Haidong Yu yuhaidong@uniontech.com
For example, calling start.bat.
Signed-off-by: Haidong Yu yuhaidong@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]);
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
This merge request was closed by Haidong Yu.
I made some modifications and added test cases.
Please see my latest merge requests.thk