Commit 7f11a24f authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

regedit: Null-terminate REG_EXPAND_SZ and REG_MULTI_SZ hex data during…

regedit: Null-terminate REG_EXPAND_SZ and REG_MULTI_SZ hex data during concatenation if we reach EOF. Signed-off-by: 's avatarHugh McMaster <hugh.mcmaster@outlook.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 82e6713b
......@@ -504,6 +504,27 @@ static void free_parser_data(struct parser *parser)
parser->data_size = 0;
}
static void prepare_hex_string_data(struct parser *parser)
{
if (parser->data_type == REG_EXPAND_SZ || parser->data_type == REG_MULTI_SZ)
{
BYTE *data = parser->data;
if (data[parser->data_size - 1] != 0)
{
data[parser->data_size] = 0;
parser->data_size++;
}
if (!parser->is_unicode)
{
parser->data = GetWideStringN(parser->data, parser->data_size, &parser->data_size);
parser->data_size *= sizeof(WCHAR);
HeapFree(GetProcessHeap(), 0, data);
}
}
}
enum reg_versions {
REG_VERSION_31,
REG_VERSION_40,
......@@ -852,23 +873,7 @@ static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos)
return line;
}
if (parser->data_type == REG_EXPAND_SZ || parser->data_type == REG_MULTI_SZ)
{
BYTE *data = parser->data;
if (data[parser->data_size - 1] != 0x00)
{
data[parser->data_size] = 0x00;
parser->data_size++;
}
if (!parser->is_unicode)
{
parser->data = GetWideStringN(parser->data, parser->data_size, &parser->data_size);
parser->data_size *= sizeof(WCHAR);
HeapFree(GetProcessHeap(), 0, data);
}
}
prepare_hex_string_data(parser);
set_state(parser, SET_VALUE);
return line;
......@@ -903,6 +908,7 @@ static WCHAR *hex_multiline_state(struct parser *parser, WCHAR *pos)
if (!(line = get_line(parser->file)))
{
prepare_hex_string_data(parser);
set_state(parser, SET_VALUE);
return pos;
}
......
......@@ -500,7 +500,7 @@ static void test_basic_import(void)
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
"\"Wine17b\"=hex(2):25,50,41,54,48,25,\\");
verify_reg(hkey, "Wine17b", REG_EXPAND_SZ, "%PATH%", 7, TODO_REG_SIZE | TODO_REG_DATA);
verify_reg(hkey, "Wine17b", REG_EXPAND_SZ, "%PATH%", 7, 0);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -510,7 +510,7 @@ static void test_basic_import(void)
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
"\"Wine17d\"=hex(7):4c,69,6e,65,\\");
verify_reg(hkey, "Wine17d", REG_MULTI_SZ, "Line", 5, TODO_REG_SIZE | TODO_REG_DATA);
verify_reg(hkey, "Wine17d", REG_MULTI_SZ, "Line", 5, 0);
exec_import_str("REGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment