From: Shawn Routhier Date: Wed, 15 Apr 2015 19:46:52 +0000 (-0700) Subject: [master] Expand use of #ifdef PACKET_AUXDATA to cover allocating cmsgbuf X-Git-Tag: v4_3_3b1~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c0b7d66b67f85c96f62d94896ad6403fffc79dc;p=thirdparty%2Fdhcp.git [master] Expand use of #ifdef PACKET_AUXDATA to cover allocating cmsgbuf 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. --- diff --git a/RELNOTES b/RELNOTES index ac4e2aee5..4050e3599 100644 --- 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 diff --git a/common/lpf.c b/common/lpf.c index cd430dd76..7889b6bbf 100644 --- a/common/lpf.c +++ b/common/lpf.c @@ -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... */