Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55928
There is no application known, which fails because of this, it just triggers UndefinedBehaviorSanitizer.
-- v3: ntdll: Align records retrieved by SystemProcessInformation.
From: Bernhard Übelacker bernhardu@mailbox.org
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55928 --- dlls/ntdll/tests/info.c | 2 ++ dlls/ntdll/unix/system.c | 1 + dlls/wow64/system.c | 1 + 3 files changed, 4 insertions(+)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index ac979760433..ee48a330400 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -662,6 +662,8 @@ static void test_query_process( BOOL extended ) } }
+ ok(((ULONG_PTR)spi & 7) == 0, "Record is not aligned at 8 byte boundary. %p\n", spi); + if (!spi->NextEntryOffset) { winetest_pop_context(); diff --git a/dlls/ntdll/unix/system.c b/dlls/ntdll/unix/system.c index d3983c0dffb..0ff3d8182de 100644 --- a/dlls/ntdll/unix/system.c +++ b/dlls/ntdll/unix/system.c @@ -2879,6 +2879,7 @@ C_ASSERT( sizeof(struct process_info) <= sizeof(SYSTEM_PROCESS_INFORMATION) );
proc_len = sizeof(*nt_process) + server_process->thread_count * thread_info_size + (name_len + 1) * sizeof(WCHAR); + proc_len = (proc_len + 7) & ~(ULONG_PTR)7; *len += proc_len;
if (*len <= size) diff --git a/dlls/wow64/system.c b/dlls/wow64/system.c index ffa82054b9a..fd10a0585ce 100644 --- a/dlls/wow64/system.c +++ b/dlls/wow64/system.c @@ -177,6 +177,7 @@ static NTSTATUS put_system_proc_info( SYSTEM_PROCESS_INFORMATION32 *info32, prev = proc32; } outpos += proc_len + proc->ProcessName.MaximumLength; + outpos = (outpos + 7) & ~(ULONG_PTR)7; inpos += proc->NextEntryOffset; if (!proc->NextEntryOffset) break; }
v3: - Use ULONG_PTR for negation and casts.
On Wed May 14 15:59:42 2025 +0000, Paul Gofman wrote:
Ah, great, thanks. You probably don't want to add #define ALIGN for one time use. I'd suggest to use a variable for (initially) unaligned result instead and just align without macros (also using it like ~(ULONG_PTR)7));
Thanks for the support, I resolved the macro and pushed a new version.
Sorry, I didn't verify at once and the values are actually ULONG so casting alignment to ULONG_PTR is excessive. While also not too bad probably, not sure that worth changing and resending.
This merge request was approved by Paul Gofman.