reg: Fail if duplicate command-line switches are passed to 'reg add'.

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-03-30 23:00:14 +11:00 committed by Alexandre Julliard
parent 9138f5893c
commit 08976b3ee0
2 changed files with 5 additions and 3 deletions

View File

@ -227,6 +227,7 @@ int reg_add(int argc, WCHAR *argvW[])
if (!lstrcmpiW(str, L"ve"))
{
if (value_empty) goto invalid;
value_empty = TRUE;
continue;
}
@ -249,11 +250,12 @@ int reg_add(int argc, WCHAR *argvW[])
break;
case 's':
str = argvW[++i];
if (!str || lstrlenW(str) != 1)
if (separator || !str || lstrlenW(str) != 1)
goto invalid;
separator = str[0];
break;
case 'f':
if (force) goto invalid;
force = TRUE;
break;
default:

View File

@ -234,7 +234,7 @@ static void test_add(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /f /f", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
open_key(HKEY_CURRENT_USER, KEY_BASE, 0, &hkey);
@ -295,7 +295,7 @@ static void test_add(void)
verify_reg(hkey, NULL, REG_SZ, "", 1, 0);
run_reg_exe("reg add HKCU\\" KEY_BASE " /ve /f /ve", &r);
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);