https://git.reactos.org/?p=reactos.git;a=commitdiff;h=20aa38c6e73a1367b7e11…
commit 20aa38c6e73a1367b7e11ca289f320782e0736d5
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Jan 17 18:43:11 2022 +0100
Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com>
CommitDate: Sun Jun 19 13:06:36 2022 +0200
[WINESYNC] reg: Fail if the source and destination keys are the same when copying.
Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 0abc002a3e232be3445241e435ef17ac89d6c947 by Hugh McMaster
<hugh.mcmaster(a)outlook.com>
manual adjustment needed
---
base/applications/cmdutils/reg/copy.c | 6 ++++++
base/applications/cmdutils/reg/reg.c | 17 +++++++----------
base/applications/cmdutils/reg/resource.h | 3 +++
sdk/tools/winesync/reg.cfg | 2 +-
4 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/base/applications/cmdutils/reg/copy.c
b/base/applications/cmdutils/reg/copy.c
index 34abf8ade18..208adc46e00 100644
--- a/base/applications/cmdutils/reg/copy.c
+++ b/base/applications/cmdutils/reg/copy.c
@@ -163,6 +163,12 @@ int reg_copy(int argc, WCHAR *argvW[])
}
}
+ if (src.root == dest.root && !lstrcmpiW(src.subkey, dest.subkey))
+ {
+ output_message(STRING_COPY_SRC_DEST_SAME);
+ return 1;
+ }
+
return run_copy(&src, &dest, recurse, force);
invalid:
diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c
index 7099cba594e..0c8eb47863c 100644
--- a/base/applications/cmdutils/reg/reg.c
+++ b/base/applications/cmdutils/reg/reg.c
@@ -206,7 +206,7 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR
*subkey_name, DWORD
WCHAR *get_long_key(HKEY root, WCHAR *path)
{
- int i, len, path_len;
+ int i, len;
WCHAR *long_key;
for (i = 0; i < ARRAY_SIZE(root_rels); i++)
@@ -224,15 +224,7 @@ WCHAR *get_long_key(HKEY root, WCHAR *path)
return long_key;
}
- path_len = lstrlenW(path);
-
- if (path[path_len - 1] == '\\')
- {
- path[path_len - 1] = 0;
- path_len--;
- }
-
- len += path_len + 1; /* add one for the concatenating backslash */
+ len += lstrlenW(path) + 1; /* add one for the concatenating backslash */
long_key = malloc((len + 1) * sizeof(WCHAR));
swprintf(long_key, L"%s\\%s", root_rels[i].long_name, path);
return long_key;
@@ -240,6 +232,8 @@ WCHAR *get_long_key(HKEY root, WCHAR *path)
BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path)
{
+ WCHAR *p;
+
if (!sane_path(key))
return FALSE;
@@ -263,6 +257,9 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path)
return FALSE;
}
+ p = *path + lstrlenW(*path) - 1;
+ if (*p == '\\') *p = 0;
+
return TRUE;
}
diff --git a/base/applications/cmdutils/reg/resource.h
b/base/applications/cmdutils/reg/resource.h
index b3f660ca13b..b7afad26d22 100644
--- a/base/applications/cmdutils/reg/resource.h
+++ b/base/applications/cmdutils/reg/resource.h
@@ -61,6 +61,9 @@
#define STRING_OVERWRITE_VALUE 205
#define STRING_INVALID_CMDLINE 206
+/* copy.c */
+#define STRING_COPY_SRC_DEST_SAME 250
+
/* delete.c */
#define STRING_DELETE_VALUE 300
#define STRING_DELETE_VALUEALL 301
diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg
index 351e3803ee8..44d7c5205ee 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: 8d9a228e99e1252a0d82c88e6a64635548c478a6
+ wine: 0abc002a3e232be3445241e435ef17ac89d6c947