[PATCH] regedit: Correctly handle the importing of DWORD strings that are followed by a comment
Hugh McMaster
hugh.mcmaster at outlook.com
Fri Apr 7 07:53:51 CDT 2017
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/regproc.c | 29 ++++++++++++++++++++++++-----
programs/regedit/tests/regedit.c | 4 ++--
2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index e0049c6..c8149f5 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -146,15 +146,34 @@ static char* GetMultiByteStringN(const WCHAR* strW, int chars, DWORD* len)
*/
static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
{
- char buf[9];
+ char *buf;
char dummy;
+ BOOL ret = TRUE;
- WideCharToMultiByte(CP_ACP, 0, str, -1, buf, 9, NULL, NULL);
- if (lstrlenW(str) > 8 || sscanf(buf, "%x%c", dw, &dummy) != 1) {
+ buf = GetMultiByteString(str);
+ if (!buf) return FALSE;
+
+ if (strlen(buf) > 8) /* Look for any characters after the DWORD string */
+ {
+ char *p = buf + 8;
+
+ while (*p == ' ' || *p == '\t') p++;
+ if (*p != ';')
+ {
+ HeapFree(GetProcessHeap(), 0, buf);
+ return FALSE;
+ }
+ buf[8] = 0;
+ }
+
+ if (sscanf(buf, "%x%c", dw, &dummy) != 1)
+ {
output_message(STRING_INVALID_HEX);
- return FALSE;
+ ret = FALSE;
}
- return TRUE;
+
+ HeapFree(GetProcessHeap(), 0, buf);
+ return ret;
}
/******************************************************************************
diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index bbe5c4b..eef599d 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -532,7 +532,7 @@ static void test_comments(void)
todo_wine verify_reg(hkey, "Wine4", REG_SZ, "Value 2", 8, 0);
verify_reg_nonexist(hkey, "Wine5");
dword = 0x2040608;
- todo_wine verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
+ verify_reg(hkey, "Wine6", REG_DWORD, &dword, sizeof(dword), 0);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
@@ -592,7 +592,7 @@ static void test_comments(void)
verify_reg_nonexist(hkey, "Wine22");
verify_reg_nonexist(hkey, "Wine23");
dword = 0x00000004;
- todo_wine verify_reg(hkey, "Wine24", REG_DWORD, &dword, sizeof(dword), 0);
+ verify_reg(hkey, "Wine24", REG_DWORD, &dword, sizeof(dword), 0);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
--
2.7.4
More information about the wine-patches
mailing list