Commit c418771a authored by Bernhard Übelacker's avatar Bernhard Übelacker Committed by Alexandre Julliard

cmd: Avoid execution if block misses closing brackets.

parent d7edf3e6
......@@ -1055,6 +1055,30 @@ if 1 == 0 (
@tab@
@tab@
) else echo block containing two lines with just tab seems to work
::
echo @if 1 == 1 (> blockclosing.cmd
echo echo with closing bracket>> blockclosing.cmd
echo )>> blockclosing.cmd
cmd.exe /Q /C blockclosing.cmd
echo %ERRORLEVEL% ok
::
echo @if 1 == 1 (> blockclosing.cmd
echo echo without closing bracket first>> blockclosing.cmd
echo echo without closing bracket second>> blockclosing.cmd
cmd.exe /Q /C blockclosing.cmd
echo %ERRORLEVEL% two lines
::
echo echo before both blocks> blockclosing.cmd
echo @if 1 == 1 (>> blockclosing.cmd
echo echo before nested block without closing bracket>> blockclosing.cmd
echo @if 2 == 2 (>> blockclosing.cmd
echo echo without closing bracket>> blockclosing.cmd
echo )>> blockclosing.cmd
echo echo outside of block without closing bracket>> blockclosing.cmd
cmd.exe /Q /C blockclosing.cmd
echo %ERRORLEVEL% nested
::
del blockclosing.cmd
echo --- case sensitivity with and without /i option
if bar==BAR echo if does not default to case sensitivity
if not bar==BAR echo if seems to default to case sensitivity
......
......@@ -713,6 +713,11 @@ block containing a line with just space and tab seems to work
block containing a line with just tab and space seems to work
block containing two lines with just space seems to work
block containing two lines with just tab seems to work
with closing bracket
0 ok
255 two lines
before both blocks
255 nested
--- case sensitivity with and without /i option
if seems to default to case sensitivity
if /i seems to work
......
......@@ -2347,6 +2347,13 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
}
}
if (curDepth > lineCurDepth) {
WINE_TRACE("Brackets do not match, error out without executing.\n");
WCMD_free_commands(*output);
*output = NULL;
errorlevel = 255;
}
/* Dump out the parsed output */
WCMD_DumpCommands(*output);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment