Commit 39e0e81c authored by Hugh McMaster's avatar Hugh McMaster Committed by Alexandre Julliard

reg: Null-terminate incomplete REG_EXPAND_SZ and REG_MULTI_SZ Unicode data.

parent e9daef47
......@@ -410,16 +410,27 @@ 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)
if (parser->is_unicode)
{
data[parser->data_size] = 0;
parser->data_size++;
}
WCHAR *data = parser->data;
DWORD len = parser->data_size / sizeof(WCHAR);
if (!parser->is_unicode)
if (data[len - 1] != 0)
{
data[len] = 0;
parser->data_size += sizeof(WCHAR);
}
}
else
{
BYTE *data = parser->data;
if (data[parser->data_size - 1] != 0)
{
data[parser->data_size] = 0;
parser->data_size++;
}
parser->data = GetWideStringN(parser->data, parser->data_size, &parser->data_size);
parser->data_size *= sizeof(WCHAR);
heap_free(data);
......
......@@ -2809,7 +2809,7 @@ static void test_unicode_import(void)
" 63,00,61,00,74,00,;comment\n"
" 65,00,6e,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00\n\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, TODO_REG_SIZE);
verify_reg(hkey, "Multi-Line2", REG_MULTI_SZ, "Line concat", 12, 0);
test_import_wstr("\xef\xbb\xbfREGEDIT4\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -3005,7 +3005,7 @@ static void test_unicode_import(void)
err = RegQueryValueExA(hkey, "Wine44i", NULL, &type, (BYTE *)&buffer, &size);
ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
todo_wine ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
/* Wine44j */
size = sizeof(buffer);
......@@ -3013,7 +3013,7 @@ static void test_unicode_import(void)
err = RegQueryValueExA(hkey, "Wine44j", NULL, &type, (BYTE *)&buffer, &size);
ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
ok(type == REG_EXPAND_SZ, "got wrong type %u, expected %u\n", type, REG_EXPAND_SZ);
todo_wine ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
ok(size == 6 || broken(size == 5) /* WinXP */, "got wrong size %u, expected 6\n", size);
ok(memcmp(buffer, "%PATH", size) == 0, "got wrong data\n");
/* Wine44k */
verify_reg_nonexist(hkey, "Wine44k");
......@@ -3649,7 +3649,7 @@ static void test_unicode_import(void)
ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
"got %u, expected 0\n", err);
if (err == ERROR_SUCCESS)
verify_reg(hkey, "Wine62b", REG_EXPAND_SZ, "%PATH%", 7, TODO_REG_SIZE);
verify_reg(hkey, "Wine62b", REG_EXPAND_SZ, "%PATH%", 7, 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -3669,7 +3669,7 @@ static void test_unicode_import(void)
ok(err == ERROR_SUCCESS || broken(err == ERROR_FILE_NOT_FOUND) /* WinXP */,
"got %u, expected 0\n", err);
if (err == ERROR_SUCCESS)
verify_reg(hkey, "Wine62d", REG_MULTI_SZ, "Line", 5, TODO_REG_SIZE);
verify_reg(hkey, "Wine62d", REG_MULTI_SZ, "Line", 5, 0);
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
"[HKEY_CURRENT_USER\\" KEY_BASE "]\n"
......@@ -3727,14 +3727,14 @@ static void test_unicode_import(void)
err = RegQueryValueExA(hkey, "Wine64d", NULL, &type, (BYTE *)&buffer, &size);
ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
todo_wine ok(size == 12 || broken(size == 11) /* WinXP */, "got wrong size %u, expected 12\n", size);
ok(size == 12 || broken(size == 11) /* WinXP */, "got wrong size %u, expected 12\n", size);
ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
/* Wine64e */
size = sizeof(buffer);
err = RegQueryValueExA(hkey, "Wine64e", NULL, &type, (BYTE *)&buffer, &size);
ok(err == ERROR_SUCCESS, "RegQueryValueExA failed: %d\n", err);
ok(type == REG_MULTI_SZ, "got wrong type %u, expected %u\n", type, REG_MULTI_SZ);
todo_wine ok(size == 12 || broken(size == 11) /* WinXP */, "got wrong size %u, expected 12\n", size);
ok(size == 12 || broken(size == 11) /* WinXP */, "got wrong size %u, expected 12\n", size);
ok(memcmp(buffer, "Line concat", size) == 0, "got wrong data\n");
test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n"
......@@ -3768,8 +3768,8 @@ static void test_unicode_import(void)
"\"Wine66e\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00\n"
"\"Wine66f\"=hex(7):4c,00,69,00,6e,00,65,00,00,00,00,00,\n\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg(hkey, "Wine66a", REG_MULTI_SZ, "Line", 5, TODO_REG_SIZE);
verify_reg(hkey, "Wine66b", REG_MULTI_SZ, "Line", 5, TODO_REG_SIZE);
verify_reg(hkey, "Wine66a", REG_MULTI_SZ, "Line", 5, 0);
verify_reg(hkey, "Wine66b", REG_MULTI_SZ, "Line", 5, 0);
verify_reg(hkey, "Wine66c", REG_MULTI_SZ, "Line", 5, 0);
verify_reg(hkey, "Wine66d", REG_MULTI_SZ, "Line", 5, 0);
verify_reg(hkey, "Wine66e", REG_MULTI_SZ, "Line\0", 6, 0);
......@@ -3782,8 +3782,8 @@ static void test_unicode_import(void)
"\"Wine67c\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00\n"
"\"Wine67d\"=hex(2):25,00,50,00,41,00,54,00,48,00,25,00,00,00,\n\n", &r);
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
verify_reg(hkey, "Wine67a", REG_EXPAND_SZ, "%PATH%", 7, TODO_REG_SIZE);
verify_reg(hkey, "Wine67b", REG_EXPAND_SZ, "%PATH%", 7, TODO_REG_SIZE);
verify_reg(hkey, "Wine67a", REG_EXPAND_SZ, "%PATH%", 7, 0);
verify_reg(hkey, "Wine67b", REG_EXPAND_SZ, "%PATH%", 7, 0);
verify_reg(hkey, "Wine67c", REG_EXPAND_SZ, "%PATH%", 7, 0);
verify_reg(hkey, "Wine67d", REG_EXPAND_SZ, "%PATH%", 7, 0);
......
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