https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e4d03f471b4b4ccac2a6c…
commit e4d03f471b4b4ccac2a6c952ae6eb89550dbbd7a
Author: Whindmar Saksit <whindsaks(a)proton.me>
AuthorDate: Mon Dec 4 16:46:06 2023 +0100
Commit: GitHub <noreply(a)github.com>
CommitDate: Mon Dec 4 16:46:06 2023 +0100
[REGEDIT][REG] Limit registry type to 8 hex digits when importing (#6063)
Matches Windows and lets the Wine13i test in regedit_winetest pass.
---
base/applications/cmdutils/reg/import.c | 5 +++++
base/applications/regedit/regproc.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/base/applications/cmdutils/reg/import.c
b/base/applications/cmdutils/reg/import.c
index 1d4e3d53536..91442cf06b3 100644
--- a/base/applications/cmdutils/reg/import.c
+++ b/base/applications/cmdutils/reg/import.c
@@ -276,7 +276,12 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line)
/* "hex(xx):" is special */
val = wcstoul(*line, &end, 16);
+#ifdef __REACTOS__
+ /* Up to 8 hex digits, "hex(000000002)" is invalid */
+ if (*end != ')' || *(end + 1) != ':' || (val == ~0u
&& errno == ERANGE) || end - *line > 8)
+#else
if (*end != ')' || *(end + 1) != ':' || (val == ~0u
&& errno == ERANGE))
+#endif
return FALSE;
parser->data_type = val;
diff --git a/base/applications/regedit/regproc.c b/base/applications/regedit/regproc.c
index 1ef1fc9e6c2..f8d448e08c8 100644
--- a/base/applications/regedit/regproc.c
+++ b/base/applications/regedit/regproc.c
@@ -339,7 +339,12 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line)
/* "hex(xx):" is special */
val = wcstoul(*line, &end, 16);
+#ifdef __REACTOS__
+ /* Up to 8 hex digits, "hex(000000002)" is invalid */
+ if (*end != ')' || *(end + 1) != ':' || (val == ~0u
&& errno == ERANGE) || end - *line > 8)
+#else
if (*end != ')' || *(end + 1) != ':' || (val == ~0u
&& errno == ERANGE))
+#endif
return FALSE;
parser->data_type = val;