From: Remi Gacogne Date: Mon, 1 Jul 2019 08:00:35 +0000 (+0200) Subject: Add static assertions for the size of the src address control buffer X-Git-Tag: dnsdist-1.4.0-rc1~79^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F8007%2Fhead;p=thirdparty%2Fpdns.git Add static assertions for the size of the src address control buffer --- diff --git a/pdns/misc.cc b/pdns/misc.cc index 2686b0fc46..6626702771 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -893,6 +893,7 @@ void addCMsgSrcAddr(struct msghdr* msgh, cmsgbuf_aligned* cmsgbuf, const ComboAd struct in6_pktinfo *pkt; msgh->msg_control = cmsgbuf; + static_assert(CMSG_SPACE(sizeof(*pkt)) <= sizeof(*cmsgbuf), "Buffer is too small for in6_pktinfo"); msgh->msg_controllen = CMSG_SPACE(sizeof(*pkt)); cmsg = CMSG_FIRSTHDR(msgh); @@ -910,6 +911,7 @@ void addCMsgSrcAddr(struct msghdr* msgh, cmsgbuf_aligned* cmsgbuf, const ComboAd struct in_pktinfo *pkt; msgh->msg_control = cmsgbuf; + static_assert(CMSG_SPACE(sizeof(*pkt)) <= sizeof(*cmsgbuf), "Buffer is too small for in_pktinfo"); msgh->msg_controllen = CMSG_SPACE(sizeof(*pkt)); cmsg = CMSG_FIRSTHDR(msgh); @@ -925,6 +927,7 @@ void addCMsgSrcAddr(struct msghdr* msgh, cmsgbuf_aligned* cmsgbuf, const ComboAd struct in_addr *in; msgh->msg_control = cmsgbuf; + static_assert(CMSG_SPACE(sizeof(*in)) <= sizeof(*cmsgbuf), "Buffer is too small for in_addr"); msgh->msg_controllen = CMSG_SPACE(sizeof(*in)); cmsg = CMSG_FIRSTHDR(msgh);