]> 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)
committerOndřej Surý <ondrej@sury.org>
Fri, 7 Sep 2018 08:27:20 +0000 (10:27 +0200)
CHANGES entry

(cherry picked from commit 17212cf9965a1a0ec8412b807fe08f74e059cc1c)

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

diff --git a/CHANGES b/CHANGES
index cb24cc40ad1f01e59ec7fd384938ef7b5c5d3443..96134f8c68bc1b6ac3a105246e89ae47f0825894 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]
+
 5028.  [bug]           Spread the initial RRSIG expiration times over the
                        entire working sig-validity-interval when signing a
                        zone in named to even out re-signing and transfer
index 332dc0c2b9bb9c71287ce194caf2a6c8eb11b874..2ed0a2a4a99143e3d05426c187447bf753aaa1cf 100644 (file)
  */
 #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 d2ee1b0dca95b8b81f3280a7c70d21e84cd75e5b..229711d238b44038e2d6aea126a4accd2a59d5ff 100644 (file)
@@ -346,8 +346,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.