Eric Pouech : cmd: Don't crash on 'if exist' without parameter.

Alexandre Julliard julliard at winehq.org
Tue Apr 12 13:38:04 CDT 2022


Module: wine
Branch: oldstable
Commit: 3bff9ccfa42613f24fe5bbedf1e80624f2570429
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3bff9ccfa42613f24fe5bbedf1e80624f2570429

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Mon Dec 20 10:29:01 2021 +0100

cmd: Don't crash on 'if exist' without parameter.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51598
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 535da77552deb74198f0fe8fedae3bbab5115ad7)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 programs/cmd/builtins.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 3f9465320c1..d8e5d061bd4 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -2815,8 +2815,9 @@ int evaluate_if_condition(WCHAR *p, WCHAR **command, int *test, int *negate)
     WCHAR *param = WCMD_parameter(p, 1+(*negate), NULL, FALSE, FALSE);
     int    len = lstrlenW(param);
 
+    if (!len) goto syntax_err;
     /* FindFirstFile does not like a directory path ending in '\', append a '.' */
-    if (len && param[len-1] == '\\') lstrcatW(param, L".");
+    if (param[len-1] == '\\') lstrcatW(param, L".");
 
     hff = FindFirstFileW(param, &fd);
     *test = (hff != INVALID_HANDLE_VALUE );




More information about the wine-cvs mailing list