reg: Abort 'delete' operation when parsing command-line arguments that are not switches.

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2021-04-02 22:26:54 +11:00 committed by Alexandre Julliard
parent b2ead1ffcc
commit 51e83dec29
1 changed files with 31 additions and 29 deletions

View File

@ -118,38 +118,40 @@ int reg_delete(int argc, WCHAR *argvW[])
for (i = 3; i < argc; i++) for (i = 3; i < argc; i++)
{ {
if (argvW[i][0] == '/' || argvW[i][0] == '-') WCHAR *str;
if (argvW[i][0] != '/' && argvW[i][0] != '-')
goto invalid;
str = &argvW[i][1];
if (!lstrcmpiW(str, L"va"))
{ {
WCHAR *str = &argvW[i][1]; if (value_all) goto invalid;
value_all = TRUE;
continue;
}
else if (!lstrcmpiW(str, L"ve"))
{
if (value_empty) goto invalid;
value_empty = TRUE;
continue;
}
else if (!str[0] || str[1])
goto invalid;
if (!lstrcmpiW(str, L"va")) switch (towlower(*str))
{ {
if (value_all) goto invalid; case 'v':
value_all = TRUE; if (value_name || !(value_name = argvW[++i]))
continue;
}
else if (!lstrcmpiW(str, L"ve"))
{
if (value_empty) goto invalid;
value_empty = TRUE;
continue;
}
else if (!str[0] || str[1])
goto invalid; goto invalid;
break;
switch (towlower(*str)) case 'f':
{ if (force) goto invalid;
case 'v': force = TRUE;
if (value_name || !(value_name = argvW[++i])) break;
goto invalid; default:
break; goto invalid;
case 'f':
if (force) goto invalid;
force = TRUE;
break;
default:
goto invalid;
}
} }
} }