[PATCH 4/4] regedit: Null-terminate concatenated comma-separated data that ends prematurely
Hugh McMaster
hugh.mcmaster at outlook.com
Wed Apr 5 06:48:52 CDT 2017
Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
programs/regedit/regproc.c | 12 ++++++++++--
programs/regedit/tests/regedit.c | 2 +-
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c
index 675a7cf..b85e277 100644
--- a/programs/regedit/regproc.c
+++ b/programs/regedit/regproc.c
@@ -160,7 +160,7 @@ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw)
/******************************************************************************
* Converts a hex comma separated values list into a binary string.
*/
-static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
+static BYTE *convertHexCSVToHex(WCHAR *str, DWORD *size, BOOL is_unicode)
{
WCHAR *s;
BYTE *d, *data;
@@ -177,6 +177,14 @@ static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size)
UINT wc;
WCHAR *end;
+ if (*s == ';')
+ {
+ int i = is_unicode ? 2 : 1;
+ memset(d, 0, i); /* null-terminate the data */
+ *size += i;
+ break;
+ }
+
wc = strtoulW(s,&end,16);
if (end == s || wc > 0xff || (*end && *end != ',')) {
output_message(STRING_CSV_HEX_ERROR, s);
@@ -420,7 +428,7 @@ static LONG setValue(WCHAR* val_name, WCHAR* val_data, BOOL is_unicode)
}
else if (dwParseType == REG_BINARY) /* Convert the binary data */
{
- lpbData = convertHexCSVToHex(val_data, &dwLen);
+ lpbData = convertHexCSVToHex(val_data, &dwLen, is_unicode);
if (!lpbData)
return ERROR_INVALID_DATA;
diff --git a/programs/regedit/tests/regedit.c b/programs/regedit/tests/regedit.c
index a37d869..e112449 100644
--- a/programs/regedit/tests/regedit.c
+++ b/programs/regedit/tests/regedit.c
@@ -608,7 +608,7 @@ static void test_comments(void)
" 63,6f,6e,\\;comment\n"
" 63,61,74,;comment\n"
" 65,6e,61,74,69,6f,6e,00,00\n\n");
- todo_wine verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
+ verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
--
2.7.4
More information about the wine-patches
mailing list