]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Expand use of #ifdef PACKET_AUXDATA to cover allocating cmsgbuf
authorShawn Routhier <sar@isc.org>
Wed, 15 Apr 2015 19:46:52 +0000 (12:46 -0700)
committerShawn Routhier <sar@isc.org>
Wed, 15 Apr 2015 19:46:52 +0000 (12:46 -0700)
Most of the use of tpacket_auxdata was alredy protected by PACKET_AUXDATA
this patch covers trying to find the proper size for the cmsgbuf.

RELNOTES
common/lpf.c

index ac4e2aee5d9d7ea966d01b808de5aa224c9f44e5..4050e3599a9528c6e201a3d203835d57bae96e5d 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -82,6 +82,12 @@ by Eric Young (eay@cryptsoft.com).
   The new configuration option is "./configure --with-atf=bind".
   [ISC-Bugs #38754]
 
+- Corrected a compilation error introduced by the fix for ISC-Bugs #22806.
+  On older linuxes that do not include the tpacket_auxdata structure don't
+  bother allocating the cmsgbuf as it isn't necessary and we don't have
+  a proper length for it.
+  [ISC-Bugs #39209]
+
                        Changes since 4.3.2rc2
 - None
 
index cd430dd765cba9adba702e9bc1913725a6ffd27d..7889b6bbf6f12510533c5adae2f96eebe3e2488f 100644 (file)
@@ -368,17 +368,30 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
        unsigned char ibuf [1536];
        unsigned bufix = 0;
        unsigned paylen;
-       unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
        struct iovec iov = {
                .iov_base = ibuf,
                .iov_len = sizeof ibuf,
        };
+#ifdef PACKET_AUXDATA
+       /*
+        * We only need cmsgbuf if we are getting the aux data and we
+        * only get the auxdata if it is actually defined
+        */
+       unsigned char cmsgbuf[CMSG_LEN(sizeof(struct tpacket_auxdata))];
        struct msghdr msg = {
                .msg_iov = &iov,
                .msg_iovlen = 1,
                .msg_control = cmsgbuf,
                .msg_controllen = sizeof(cmsgbuf),
        };
+#else
+       struct msghdr msg = {
+               .msg_iov = &iov,
+               .msg_iovlen = 1,
+               .msg_control = NULL,
+               .msg_controllen = 0,
+       };
+#endif /* PACKET_AUXDATA */
 
        length = recvmsg (interface->rfdesc, &msg, 0);
        if (length <= 0)
@@ -422,7 +435,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
        }
 
        }
-#endif
+#endif /* PACKET_AUXDATA */
 
        bufix = 0;
        /* Decode the physical header... */