[PATCH 4/4] reg: Fail if one or more arguments follow a help switch
Hugh McMaster
hugh.mcmaster at outlook.com
Mon May 17 08:41:06 CDT 2021
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/reg/reg.c | 13 ++++++++-----
programs/reg/tests/copy.c | 8 ++++----
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
index 652fb19d931..8d3bf78f0a9 100644
--- a/programs/reg/reg.c
+++ b/programs/reg/reg.c
@@ -349,14 +349,12 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
return 1;
}
else if (argc == 2) /* Valid operation, no arguments supplied */
- {
- output_message(STRING_INVALID_SYNTAX);
- output_message(STRING_FUNC_HELP, wcsupr(argvW[1]));
- return 1;
- }
+ goto invalid;
if (is_help_switch(argvW[2]))
{
+ if (argc > 3) goto invalid;
+
output_message(op_help);
output_message(STRING_REG_VIEW_USAGE);
return 0;
@@ -378,4 +376,9 @@ int __cdecl wmain(int argc, WCHAR *argvW[])
return reg_import(argc, argvW);
return reg_query(argc, argvW);
+
+invalid:
+ output_message(STRING_INVALID_SYNTAX);
+ output_message(STRING_FUNC_HELP, wcsupr(argvW[1]));
+ return 1;
}
diff --git a/programs/reg/tests/copy.c b/programs/reg/tests/copy.c
index ecd3cc5b29d..5ddcc2c0ffa 100644
--- a/programs/reg/tests/copy.c
+++ b/programs/reg/tests/copy.c
@@ -37,16 +37,16 @@ static void test_command_syntax(void)
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
run_reg_exe("reg copy /? /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);
run_reg_exe("reg copy /h /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);
run_reg_exe("reg copy /? /s", &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 copy /h /s", &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 copy /f", &r);
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
--
2.31.1
More information about the wine-devel
mailing list