]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Align CMSG buffers to a void* boundary, fixes crash on architectures with strict...
authorWitold Kręcicki <wpk@isc.org>
Fri, 7 Sep 2018 07:34:32 +0000 (09:34 +0200)
committerWitold Kręcicki <wpk@isc.org>
Fri, 7 Sep 2018 07:34:32 +0000 (09:34 +0200)
CHANGES entry

CHANGES
lib/isc/include/isc/util.h
lib/isc/unix/socket.c

diff --git a/CHANGES b/CHANGES
index 60d0c4cbfc1e432f77f015814d35a205f971fa45..959a8d32ec4cff0a2c644b1a8162686009c64387 100644 (file)
--- 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
index bb0c8854a88eba17b5854f7a0451f2f40b4a2f43..acc3d64c6494878ed57f14a7d1a55347fc39fc26 100644 (file)
@@ -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
  */
index 343cec2234c1eec2d21ea6afe5d001837ed74312..62a00cddac24d062de9e32fa90dcb2d778018117 100644 (file)
@@ -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.