[PATCH] regedit: Do not import DWORD values beginning with "0x" (v2)
Hugh McMaster
hugh.mcmaster at outlook.com
Mon Apr 10 06:30:36 CDT 2017
Changes since version 1:
* Move tolower() usage
* Improve error handling
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/regproc.c | 18 ++++++++++++------
programs/regedit/tests/regedit.c | 2 +-
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 932bc15..f0e49f1 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -148,23 +148,29 @@ static char* GetMultiByteStringN(const WCHAR* strW, int chars, DWORD* len)
static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
{
char *buf, *end;
+ BOOL ret = TRUE;
buf = GetMultiByteString(str);
if (!buf) return FALSE;
+ while (*buf == ' ' || *buf == '\t') buf++;
+ if (tolower(buf[1]) == 'x')
+ {
+ ret = FALSE;
+ goto exit;
+ }
+
*dw = strtoul(buf, &end, 16);
while (*end == ' ' || *end == '\t') end++;
if (buf == end || (*dw == ~0u && errno == ERANGE) || (*end && *end != ';'))
- {
- output_message(STRING_INVALID_HEX);
- HeapFree(GetProcessHeap(), 0, buf);
- return FALSE;
- }
+ ret = FALSE;
+ exit:
+ if (!ret) output_message(STRING_INVALID_HEX);
HeapFree(GetProcessHeap(), 0, buf);
- return TRUE;
+ return ret;
}
/******************************************************************************
diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index eff0772..5db2f4f 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -528,7 +528,7 @@ static void test_invalid_import(void)
"\"Test14a\"=dword:0x123\n"
"\"Test14b\"=dword:123 456\n"
"\"Test14c\"=dword:1234 5678\n\n");
- todo_wine verify_reg_nonexist(hkey, "Test14a");
+ verify_reg_nonexist(hkey, "Test14a");
verify_reg_nonexist(hkey, "Test14b");
verify_reg_nonexist(hkey, "Test14c");
--
2.7.4
More information about the wine-patches
mailing list