https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9b424b0080789efea28a7…
commit 9b424b0080789efea28a72285e8589c870f1b6b1
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Sun Jan 16 20:56:12 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:31 2022 +0200
[WINESYNC] reg: Improve initial syntax checks during the 'export' operation.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 4df5c1641e7091f42c2313b275d999f2b9d25eff by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
manual adjustment needed
---
base/applications/cmdutils/reg/export.c | 28 +++++++++++++++++-----------
base/applications/cmdutils/reg/reg.c | 10 ++++++----
base/applications/cmdutils/reg/reg.h | 1 +
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/base/applications/cmdutils/reg/export.c
b/base/applications/cmdutils/reg/export.c
index 74c6ecf195d..5e84369a234 100644
--- a/base/applications/cmdutils/reg/export.c
+++ b/base/applications/cmdutils/reg/export.c
@@ -344,27 +344,33 @@ static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file)
return hFile;
}
-static BOOL is_overwrite_switch(const WCHAR *s)
-{
- return is_switch(s, 'y');
-}
-
int reg_export(int argc, WCHAR *argvW[])
{
HKEY root, hkey;
WCHAR *path, *long_key;
BOOL overwrite_file = FALSE;
HANDLE hFile;
- int ret;
+ int i, ret;
- if (argc == 3 || argc > 5)
- goto error;
+ if (argc < 4) goto invalid;
if (!parse_registry_key(argvW[2], &root, &path, &long_key))
return 1;
- if (argc == 5 && !(overwrite_file = is_overwrite_switch(argvW[4])))
- goto error;
+ for (i = 4; i < argc; i++)
+ {
+ WCHAR *str;
+
+ if (argvW[i][0] != '/' && argvW[i][0] != '-')
+ goto invalid;
+
+ str = &argvW[i][1];
+
+ if (is_char(*str, 'y') && !str[1])
+ overwrite_file = TRUE;
+ else
+ goto invalid;
+ }
if (RegOpenKeyExW(root, path, 0, KEY_READ, &hkey))
{
@@ -382,7 +388,7 @@ int reg_export(int argc, WCHAR *argvW[])
return ret;
-error:
+invalid:
output_message(STRING_INVALID_SYNTAX);
output_message(STRING_FUNC_HELP, _wcsupr(argvW[1]));
return 1;
diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c
index 07e3a7ce97b..c275b4b8d27 100644
--- a/base/applications/cmdutils/reg/reg.c
+++ b/base/applications/cmdutils/reg/reg.c
@@ -250,15 +250,17 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path,
WCHAR **long
return TRUE;
}
+BOOL is_char(const WCHAR s, const WCHAR c)
+{
+ return (s == c || s == towupper(c));
+}
+
BOOL is_switch(const WCHAR *s, const WCHAR c)
{
if (lstrlenW(s) > 2)
return FALSE;
- if ((s[0] == '/' || s[0] == '-') && (s[1] == c || s[1] ==
towupper(c)))
- return TRUE;
-
- return FALSE;
+ return ((s[0] == '/' || s[0] == '-') && is_char(s[1], c));
}
static BOOL is_help_switch(const WCHAR *s)
diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h
index 3525bed75b8..c7719a6e4f0 100644
--- a/base/applications/cmdutils/reg/reg.h
+++ b/base/applications/cmdutils/reg/reg.h
@@ -40,6 +40,7 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info);
HKEY path_get_rootkey(const WCHAR *path);
WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD
subkey_len);
BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key);
+BOOL is_char(const WCHAR s, const WCHAR c);
BOOL is_switch(const WCHAR *s, const WCHAR c);
/* add.c */
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index 7479d9dbf89..d0b804e2ede 100644
--- a/sdk/tools/winesync/reg.cfg
+++ b/sdk/tools/winesync/reg.cfg
@@ -4,4 +4,4 @@ directories:
files:
programs/reg/resource.h: base/applications/cmdutils/reg/resource.h
tags:
- wine: 1b746c1e1c4da4a07a1293fe9e60429867c86697
+ wine: 4df5c1641e7091f42c2313b275d999f2b9d25eff