Instead of multiplying it by 2. I don't know how this ever worked.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54808
-- v5: ntdll: Increment offset by len in build_clr_surrogate_section. kernel32/tests: Check that lpSectionBase != NULL before dereferencing.
From: Alex Henrie alexhenrie24@gmail.com
If lpSectionBase is null then the tests will still crash, but at least we'll know why. --- dlls/kernel32/tests/actctx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index da351e70466..3d547e01b19 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -1454,8 +1454,8 @@ static void test_find_activatable_class(HANDLE handle, const WCHAR *classid, enu ok_(__FILE__, line)(data.lpData != NULL, "got lpData %p\n", data.lpData);
header = (struct strsection_header *)data.lpSectionBase; - ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08lx\n", header->magic); ok_(__FILE__, line)(data.lpSectionBase != NULL, "got lpSectionBase %p\n", data.lpSectionBase); + ok_(__FILE__, line)(header->magic == 0x64487353, "got wrong magic 0x%08lx\n", header->magic); ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "got ulSectionTotalLength %lu\n", data.ulSectionTotalLength); ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE *)header + header->global_offset, "got lpSectionGlobalData %p\n", data.lpSectionGlobalData); @@ -1706,10 +1706,10 @@ static void test_find_com_redirection(HANDLE handle, const GUID *clsid, const GU }
header = (struct guidsection_header*)data.lpSectionBase; + ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); ok_(__FILE__, line)(data.lpSectionGlobalData == ((BYTE*)header + header->names_offset), "data.lpSectionGlobalData == NULL\n"); ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->names_len, "data.ulSectionGlobalDataLength=%lu\n", data.ulSectionGlobalDataLength); - ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n", data.ulSectionTotalLength); ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); @@ -1914,9 +1914,9 @@ static void test_find_progid_redirection(HANDLE handle, const GUID *clsid, const }
header = (struct strsection_header*)data.lpSectionBase; + ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); ok_(__FILE__, line)(data.lpSectionGlobalData == (BYTE*)header + header->global_offset, "data.lpSectionGlobalData == NULL\n"); ok_(__FILE__, line)(data.ulSectionGlobalDataLength == header->global_len, "data.ulSectionGlobalDataLength=%lu\n", data.ulSectionGlobalDataLength); - ok_(__FILE__, line)(data.lpSectionBase != NULL, "data.lpSectionBase == NULL\n"); ok_(__FILE__, line)(data.ulSectionTotalLength > 0, "data.ulSectionTotalLength=%lu\n", data.ulSectionTotalLength); ok_(__FILE__, line)(data.hActCtx == NULL, "data.hActCtx=%p\n", data.hActCtx); ok_(__FILE__, line)(data.ulAssemblyRosterIndex == exid, "data.ulAssemblyRosterIndex=%lu, expected %lu\n",
From: Alex Henrie alexhenrie24@gmail.com
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++; } }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=132073
Your paranoid android.
=== w7pro64 (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w864 (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w1064v1507 (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w1064v1809 (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w1064_2qxl (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w1064_adm (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w1064_tsign (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w10pro64 (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w10pro64_en_AE_u8 (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w10pro64_ar (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w10pro64_ja (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w10pro64_zh_CN (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
=== w11pro64_amd (64 bit report) ===
kernel32: actctx.c:2839: Test failed: got error 14105
On Thu Apr 20 14:40:30 2023 +0000, Nikolay Sivov wrote:
That's what I did in https://gitlab.winehq.org/wine/wine/-/merge_requests/2618#note_30547.
As requested, I have reverted to the previous version of the tests, plus your changes without any modifications whatsoever.
This merge request was approved by Nikolay Sivov.