From: Flavio Cruz Date: Sun, 30 Apr 2023 03:02:20 +0000 (-0400) Subject: Make __mach_msg_destroy portable for x86_64 X-Git-Tag: glibc-2.38~318 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b25b6ca4e30a114c5af4086ed04e2f2de7077e5;p=thirdparty%2Fglibc.git Make __mach_msg_destroy portable for x86_64 We need to align on uintptr_t to make this work for x86_64, otherwise things will go wrong when RPCs return errors. Message-Id: --- diff --git a/mach/msg-destroy.c b/mach/msg-destroy.c index 7429ecbc2d7..0a8b46c8953 100644 --- a/mach/msg-destroy.c +++ b/mach/msg-destroy.c @@ -38,6 +38,7 @@ * */ +#include #if 1 #include #else @@ -162,9 +163,10 @@ __mach_msg_destroy (mach_msg_header_t *msg) saddr += sizeof(mach_msg_type_t); } - /* calculate length of data in bytes, rounding up */ - length = (((((number * size) + 7) >> 3) + sizeof (int) - 1) - &~ (sizeof (int) - 1)); + /* Calculate length of data in bytes... */ + length = ((number * size) + 7) >> 3; + /* ... and round up using uintptr_t alignment */ + length = ALIGN_UP (length, __alignof__ (uintptr_t)); addr = is_inline ? saddr : * (vm_offset_t *) saddr; @@ -177,7 +179,6 @@ __mach_msg_destroy (mach_msg_header_t *msg) } if (is_inline) { - /* inline data sizes round up to int boundaries */ saddr += length; } else { mach_msg_destroy_memory(addr, length);