[PATCH 2/2] reg: Fail if duplicate command-line switches are passed to 'reg query'

Hugh McMaster hugh.mcmaster at outlook.com
Fri Mar 26 06:25:43 CDT 2021


Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 programs/reg/query.c       | 4 +++-
 programs/reg/tests/query.c | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/programs/reg/query.c b/programs/reg/query.c
index 35d26488771..c8277cd7114 100644
--- a/programs/reg/query.c
+++ b/programs/reg/query.c
@@ -344,19 +344,21 @@ int reg_query(int argc, WCHAR *argvW[])
 
             if (!lstrcmpiW(str, L"ve"))
             {
+                if (value_empty) goto invalid;
                 value_empty = TRUE;
                 continue;
             }
             else if (!str[0] || str[1])
                 goto invalid;
 
-            switch (towlower(*s))
+            switch (towlower(*str))
             {
             case 'v':
                 if (value_name || !(value_name = argvW[++i]))
                     goto invalid;
                 break;
             case 's':
+                if (recurse) goto invalid;
                 recurse = TRUE;
                 break;
             default:
diff --git a/programs/reg/tests/query.c b/programs/reg/tests/query.c
index fcd43a4b195..e2b438f8c92 100644
--- a/programs/reg/tests/query.c
+++ b/programs/reg/tests/query.c
@@ -117,7 +117,7 @@ static void test_query(void)
        "got exit code %d, expected 0\n", r);
 
     run_reg_exe("reg query HKCU\\" KEY_BASE " /s /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);
 
     /* Clean-up, then query */
     delete_key(key, "subkey");
-- 
2.31.0




More information about the wine-devel mailing list