From 7af7ff872b3b1f3ab82a2b666cae2bd3d9401006 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Thu, 20 Apr 2023 09:03:47 -0600 Subject: [PATCH] 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 --- 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\"" " />" +" " " 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++; } }