reg: Do not allow duplicate /d or /t 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 2016-06-08 10:47:56 +00:00 committed by Alexandre Julliard
parent 078f192c66
commit 31efcc634a
2 changed files with 16 additions and 2 deletions

View File

@ -941,10 +941,16 @@ int wmain(int argc, WCHAR *argvW[])
else if (!lstrcmpiW(argvW[i], slashVAW))
value_all = TRUE;
else if (!lstrcmpiW(argvW[i], slashTW))
type = argvW[++i];
{
if (type || !(type = argvW[++i]))
{
output_message(STRING_INVALID_CMDLINE);
return 1;
}
}
else if (!lstrcmpiW(argvW[i], slashDW))
{
if (!(data = argvW[++i]))
if (data || !(data = argvW[++i]))
{
output_message(STRING_INVALID_CMDLINE);
return 1;

View File

@ -442,6 +442,14 @@ static void test_add(void)
RegCloseKey(hkey);
/* Test duplicate switches */
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup1 /t REG_DWORD /d 123 /f /t REG_SZ", &r);
ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
"got exit code %u, expected 1\n", r);
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dup2 /t REG_DWORD /d 123 /f /d 456", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %u, expected 1\n", r);
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE);
ok(err == ERROR_SUCCESS, "got %d\n", err);
}