From: Roy Marples Date: Tue, 3 May 2016 10:55:57 +0000 (+0000) Subject: Explain to Coverity why overrunning sockaddr_ll for IPoIB interfaces can happen and... X-Git-Tag: v6.11.0~51 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=359ee5b8b517daa258334aa58f7f6a12e55c8b0d;p=thirdparty%2Fdhcpcd.git Explain to Coverity why overrunning sockaddr_ll for IPoIB interfaces can happen and is catered for. --- diff --git a/if-linux.c b/if-linux.c index bd6baaae..3f526f3e 100644 --- a/if-linux.c +++ b/if-linux.c @@ -1286,10 +1286,15 @@ if_sendrawpacket(const struct interface *ifp, uint16_t protocol, su.sll.sll_ifindex = (int)ifp->index; su.sll.sll_hatype = htons(ifp->family); su.sll.sll_halen = (unsigned char)ifp->hwlen; - if (ifp->family == ARPHRD_INFINIBAND) + if (ifp->family == ARPHRD_INFINIBAND) { + /* sockaddr_ll is not big enough for IPoIB which is why + * sockaddr_storage is included in the union. + * Ugly as sin, but it works. */ + /* coverity[buffer-size] */ + /* coverity[overrun-buffer-arg] */ memcpy(&su.sll.sll_addr, &ipv4_bcast_addr, sizeof(ipv4_bcast_addr)); - else + } else memset(&su.sll.sll_addr, 0xff, ifp->hwlen); fd = ipv4_protocol_fd(ifp, protocol);