Module: wine Branch: master Commit: 7af7ff872b3b1f3ab82a2b666cae2bd3d9401006 URL: https://gitlab.winehq.org/wine/wine/-/commit/7af7ff872b3b1f3ab82a2b666cae2bd...
Author: Alex Henrie alexhenrie24@gmail.com Date: Thu Apr 20 09:03:47 2023 -0600
ntdll: Increment offset by len in build_clr_surrogate_section.
Instead of multiplying it by 2.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54808 Co-authored-by: Nikolay Sivov nsivov@codeweavers.com
---
dlls/kernel32/tests/actctx.c | 38 +++++++++++++++++++++++++++++++++++++- dlls/ntdll/actctx.c | 2 +- 2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index 3d547e01b19..2225215be8a 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -147,6 +147,11 @@ static const char manifest3[] = " name="testsurrogate"" " runtimeVersion="v2.0.50727"" " />" +" <clrSurrogate " +" clsid="{96666666-8888-7777-6666-555555555556}"" +" name="testsurrogate"" +" runtimeVersion="v2.0.50728"" +" />" " <clrClass " " clsid="{22345678-1234-5678-1234-111122223333}"" " name="clrclass"" @@ -1592,6 +1597,29 @@ struct clrclass_data { DWORD res2[2]; };
+static void validate_guid_index(const ACTCTX_SECTION_KEYED_DATA *data, int line) +{ +#define GUIDSECTION_MAGIC 0x64487347 /* dHsG */ + struct guidsection_header *header; + struct guid_index *index; + unsigned int i; + + header = (struct guidsection_header *)data->lpSectionBase; + + ok_(__FILE__, line)(header->magic == GUIDSECTION_MAGIC, "Unexpected magic %#lx.\n", header->magic); + ok_(__FILE__, line)(header->size == sizeof(*header), "Unexpected size %ld.\n", header->size); + ok_(__FILE__, line)(header->index_offset >= sizeof(*header), "Unexpected index offset %lu.\n", header->index_offset); + + index = (struct guid_index *)((BYTE *)data->lpSectionBase + header->index_offset); + for (i = 0; i < header->count; ++i) + { + ok_(__FILE__, line)(index[i].data_len <= data->ulSectionTotalLength, "Unexpected data length.\n"); + ok_(__FILE__, line)(index[i].data_offset <= data->ulSectionTotalLength - index[i].data_len, + "Unexpected data offset %ld, section total length %lu, data length %lu.\n", + index[i].data_offset, data->ulSectionTotalLength, index[i].data_len); + } +} + static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GUID *tlid, const WCHAR *progid, ULONG exid, int line) { struct comclassredirect_data *comclass, *comclass2; @@ -1715,6 +1743,7 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n", data.ulAssemblyRosterIndex, exid); + validate_guid_index(&data, line);
/* generated guid for this class works as key guid in search */ memset(&data2, 0xfe, sizeof(data2)); @@ -1801,6 +1830,8 @@ static void test_find_ifaceps_redirection(HANDLE handle, const GUID *iid, const ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n", data.ulAssemblyRosterIndex, exid); + + validate_guid_index(&data, line); }
struct clrsurrogate_data @@ -1815,7 +1846,7 @@ struct clrsurrogate_data };
static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *name, const WCHAR *version, - ULONG exid, int line) + ULONG exid, int line) { struct clrsurrogate_data *surrogate; ACTCTX_SECTION_KEYED_DATA data; @@ -1871,6 +1902,8 @@ static void test_find_surrogate(HANDLE handle, const GUID *clsid, const WCHAR *n ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n", data.ulAssemblyRosterIndex, exid); + + validate_guid_index(&data, line); }
static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const char *progid, ULONG exid, int line) @@ -1911,6 +1944,8 @@ static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const comclass = (struct comclassredirect_data*)data2.lpData; ok_(__FILE__, line)(IsEqualGUID(guid, &comclass->alias), "got wrong alias referenced from progid %s, %s\n", progid, wine_dbgstr_guid(guid)); ok_(__FILE__, line)(IsEqualGUID(clsid, &comclass->clsid), "got wrong class referenced from progid %s, %s\n", progid, wine_dbgstr_guid(clsid)); + + validate_guid_index(&data2, line); }
header = (struct strsection_header*)data.lpSectionBase; @@ -2076,6 +2111,7 @@ static void test_typelib_section(void) section = (struct guidsection_header*)data.lpSectionBase; ok(section->count == 4, "got %ld\n", section->count); ok(section->size == sizeof(*section), "got %ld\n", section->size); + validate_guid_index(&data, __LINE__);
/* For both GUIDs same section is returned */ ok(data.lpSectionBase == data2.lpSectionBase, "got %p, %p\n", data.lpSectionBase, data2.lpSectionBase); diff --git a/dlls/ntdll/actctx.c b/dlls/ntdll/actctx.c index 08a4893a85d..54167a2db67 100644 --- a/dlls/ntdll/actctx.c +++ b/dlls/ntdll/actctx.c @@ -4828,7 +4828,7 @@ static NTSTATUS build_clr_surrogate_section(ACTIVATION_CONTEXT* actctx, struct g ptrW[data->version_len/sizeof(WCHAR)] = 0; }
- data_offset += index->data_offset; + data_offset += index->data_len; index++; } }