]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- sendmsg()/recvmsg() control buffers are now declared in such a way to
authorDavid Hankins <dhankins@isc.org>
Tue, 23 Oct 2007 21:39:56 +0000 (21:39 +0000)
committerDavid Hankins <dhankins@isc.org>
Tue, 23 Oct 2007 21:39:56 +0000 (21:39 +0000)
  ensure they are correctly aligned on all (esp. 64-bit) architectures.
  [ISC-Bugs #17087b]

RELNOTES
common/socket.c

index 40d161cb0915752ceb94908dd31355345498820e..1b858125c616dc5c95656d57278c39c28f076255 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -61,6 +61,9 @@ suggested fixes to <dhcp-users@isc.org>.
   'never used' leases will no longer consistently shift between servers
   on every pool rebalance run.
 
+- sendmsg()/recvmsg() control buffers are now declared in such a way to
+  ensure they are correctly aligned on all (esp. 64-bit) architectures.
+
                        Changes since 4.0.0a3
 
 - The DHCP server no longer requires a "ddns-update-style" statement, 
index 13904a35e8d9b0758525121bfb127a57cd0bc52c..b3d4ef3e7205547727a1a2b91107c155585fa825 100644 (file)
@@ -437,8 +437,11 @@ ssize_t send_packet6(struct interface_info *interface,
        struct iovec v;
        int result;
        struct in6_pktinfo *pktinfo;
-       char pbuf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
        struct cmsghdr *cmsg;
+       union {
+               struct cmsghdr cmsg_sizer;
+               u_int8_t pktinfo_sizer[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+       } control_buf;
 
        /*
         * Initialize our message header structure.
@@ -469,8 +472,8 @@ ssize_t send_packet6(struct interface_info *interface,
         * source address if we wanted, but we can safely let the
         * kernel decide what that should be. 
         */
-       m.msg_control = pbuf;
-       m.msg_controllen = sizeof(pbuf);
+       m.msg_control = &control_buf;
+       m.msg_controllen = sizeof(control_buf);
        cmsg = CMSG_FIRSTHDR(&m);
        cmsg->cmsg_level = IPPROTO_IPV6;
        cmsg->cmsg_type = IPV6_PKTINFO;
@@ -530,11 +533,14 @@ receive_packet6(struct interface_info *interface,
                struct sockaddr_in6 *from, struct in6_addr *to_addr) {
        struct msghdr m;
        struct iovec v;
-       char pbuf[CMSG_SPACE(sizeof(struct in6_pktinfo))];
        int result;
        struct cmsghdr *cmsg;
        struct in6_pktinfo *pktinfo;
        int found_to_addr;
+       union {
+               struct cmsghdr cmsg_sizer;
+               u_int8_t pktinfo_sizer[CMSG_SPACE(sizeof(struct in6_pktinfo))];
+       } control_buf;
 
        /*
         * Initialize our message header structure.
@@ -565,8 +571,8 @@ receive_packet6(struct interface_info *interface,
         * information (when we initialized the interface), so we
         * should get the destination address from that.
         */
-       m.msg_control = pbuf;
-       m.msg_controllen = sizeof(pbuf);
+       m.msg_control = &control_buf;
+       m.msg_controllen = sizeof(control_buf);
 
        result = recvmsg(interface->rfdesc, &m, 0);