From: Witold Kręcicki Date: Fri, 7 Sep 2018 07:34:32 +0000 (+0200) Subject: Align CMSG buffers to a void* boundary, fixes crash on architectures with strict... X-Git-Tag: v9.13.4~158^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=17212cf9965a1a0ec8412b807fe08f74e059cc1c;p=thirdparty%2Fbind9.git Align CMSG buffers to a void* boundary, fixes crash on architectures with strict alignment CHANGES entry --- diff --git a/CHANGES b/CHANGES index 60d0c4cbfc1..959a8d32ec4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5030. [bug] Align CMSG buffers to a 64-bit boundary, fixes crash + on architectures with strict alignment. [GL #521] + --- 9.13.3 released --- 5029. [func] Workarounds for servers that misbehave when queried diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index bb0c8854a88..acc3d64c649 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -259,6 +259,11 @@ extern void mock_assert(const int result, const char* const expression, */ #define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS) +/*% + * Alignment + */ +#define ALIGN(x, a) (((x) + (a) - 1) & ~((typeof(x))(a)-1)) + /*% * Misc */ diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 343cec2234c..62a00cddac2 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -315,8 +315,9 @@ typedef isc_event_t intev_t; #define CMSG_SP_INT 24 -#define RECVCMSGBUFLEN (2*(CMSG_SP_IN6PKT + CMSG_SP_TIMESTAMP + CMSG_SP_TCTOS)+1) -#define SENDCMSGBUFLEN (2*(CMSG_SP_IN6PKT + CMSG_SP_INT + CMSG_SP_TCTOS)+1) +/* Align cmsg buffers to be safe on SPARC etc. */ +#define RECVCMSGBUFLEN ALIGN(2*(CMSG_SP_IN6PKT + CMSG_SP_TIMESTAMP + CMSG_SP_TCTOS)+1, sizeof(void*)) +#define SENDCMSGBUFLEN ALIGN(2*(CMSG_SP_IN6PKT + CMSG_SP_INT + CMSG_SP_TCTOS)+1, sizeof(void*)) /*% * The number of times a send operation is repeated if the result is EINTR.