]> 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:30:12 +0000 (10:30 +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 a72ae36d8a42e75e46099eea0493c9ac34786b47..500c74cab7e4e4738d9d94efa645a13796c7e395 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 f844124d74b2d62465f5f3066e8c61505e0bf871..946feb0d67190766d90b8d8ad82ac720c225a39e 100644 (file)
@@ -347,8 +347,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.