Brendan Shanks : ntdll: Avoid truncating pointer to 32-bits in get_cpu_area().

Alexandre Julliard julliard at winehq.org
Fri May 20 15:26:49 CDT 2022


Module: wine
Branch: master
Commit: fe52b067bf9a9733e4c6929f63ab13363b87d39e
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=fe52b067bf9a9733e4c6929f63ab13363b87d39e

Author: Brendan Shanks <bshanks at codeweavers.com>
Date:   Tue May 17 13:32:29 2022 -0700

ntdll: Avoid truncating pointer to 32-bits in get_cpu_area().

Signed-off-by: Brendan Shanks <bshanks at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/process.c     | 2 +-
 dlls/ntdll/unix/thread.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index 7b36c988e81..0b4245fdd42 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -161,7 +161,7 @@ NTSTATUS WINAPI RtlWow64GetCpuAreaInfo( WOW64_CPURESERVED *cpu, ULONG reserved,
 
     for (i = 0; i < ARRAY_SIZE(data); i++)
     {
-#define ALIGN(ptr,align) ((void *)(((ULONG_PTR)(ptr) + (align) - 1) & ~((align) - 1)))
+#define ALIGN(ptr,align) ((void *)(((ULONG_PTR)(ptr) + (align) - 1) & ~((ULONG_PTR)(align) - 1)))
         if (data[i].machine != cpu->Machine) continue;
         info->Context = ALIGN( cpu + 1, data[i].align );
         info->ContextEx = ALIGN( (char *)info->Context + data[i].size, sizeof(void *) );
diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c
index 503230e4634..6d937675bcb 100644
--- a/dlls/ntdll/unix/thread.c
+++ b/dlls/ntdll/unix/thread.c
@@ -1111,7 +1111,7 @@ void *get_cpu_area( USHORT machine )
     case IMAGE_FILE_MACHINE_ARM64: align = TYPE_ALIGNMENT(ARM64_NT_CONTEXT); break;
     default: return NULL;
     }
-    return (void *)(((ULONG_PTR)(cpu + 1) + align - 1) & ~(align - 1));
+    return (void *)(((ULONG_PTR)(cpu + 1) + align - 1) & ~((ULONG_PTR)align - 1));
 }
 
 




More information about the wine-cvs mailing list