summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2019-05-17 23:38:31 +0200
committerQuentin Young <qlyoung@cumulusnetworks.com>2019-05-17 23:38:31 +0200
commitab059defe31ce23cc01aed66af8d26288b2e0011 (patch)
treea893592c2c37c4aab56d6c2f7faab88d31663685
parentvrrpd: const vrrp_hash_key (diff)
downloadfrr-ab059defe31ce23cc01aed66af8d26288b2e0011.tar.xz
frr-ab059defe31ce23cc01aed66af8d26288b2e0011.zip
vrrpd: fix coverity warnings
* Suppress false positive on out of bounds access * Suppress false positive on unchecked str2sockunion * Remove self assignment * Initialze struct msghdr to zero Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r--vrrpd/vrrp.c5
-rw-r--r--vrrpd/vrrp_arp.c10
-rw-r--r--vrrpd/vrrp_ndisc.c5
3 files changed, 15 insertions, 5 deletions
diff --git a/vrrpd/vrrp.c b/vrrpd/vrrp.c
index ad09caf35..3d535cbfb 100644
--- a/vrrpd/vrrp.c
+++ b/vrrpd/vrrp.c
@@ -763,7 +763,7 @@ static void vrrp_send_advertisement(struct vrrp_router *r)
const char *group = r->family == AF_INET ? VRRP_MCASTV4_GROUP_STR
: VRRP_MCASTV6_GROUP_STR;
- str2sockunion(group, &dest);
+ (void)str2sockunion(group, &dest);
ssize_t sent = sendto(r->sock_tx, pkt, (size_t)pktsz, 0, &dest.sa,
sockunion_sizeof(&dest));
@@ -969,7 +969,7 @@ static int vrrp_read(struct thread *thread)
uint8_t control[64];
struct ipaddr src = {};
- struct msghdr m;
+ struct msghdr m = {};
struct iovec iov;
iov.iov_base = r->ibuf;
@@ -1384,7 +1384,6 @@ static void vrrp_change_state_backup(struct vrrp_router *r)
*/
static void vrrp_change_state_initialize(struct vrrp_router *r)
{
- r->vr->advertisement_interval = r->vr->advertisement_interval;
r->master_adver_interval = 0;
vrrp_recalculate_timers(r);
diff --git a/vrrpd/vrrp_arp.c b/vrrpd/vrrp_arp.c
index 8e903e137..78e153a08 100644
--- a/vrrpd/vrrp_arp.c
+++ b/vrrpd/vrrp_arp.c
@@ -124,7 +124,7 @@ void vrrp_garp_send(struct vrrp_router *r, struct in_addr *v4)
if (ifp->flags & IFF_NOARP) {
zlog_warn(
VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
- "Unable to send gratuitous ARP on %s; has IFF_NOARP\n",
+ "Unable to send gratuitous ARP on %s; has IFF_NOARP",
r->vr->vrid, family2str(r->family), ifp->name);
return;
}
@@ -132,6 +132,14 @@ void vrrp_garp_send(struct vrrp_router *r, struct in_addr *v4)
/* Build garp */
garpbuf_len = vrrp_build_garp(garpbuf, ifp, v4);
+ if (garpbuf_len < 0) {
+ zlog_warn(
+ VRRP_LOGPFX VRRP_LOGPFX_VRID VRRP_LOGPFX_FAM
+ "Unable to send gratuitous ARP on %s; MAC address unknown",
+ r->vr->vrid, family2str(r->family), ifp->name);
+ return;
+ };
+
/* Send garp */
inet_ntop(AF_INET, v4, astr, sizeof(astr));
diff --git a/vrrpd/vrrp_ndisc.c b/vrrpd/vrrp_ndisc.c
index 8081533eb..348958509 100644
--- a/vrrpd/vrrp_ndisc.c
+++ b/vrrpd/vrrp_ndisc.c
@@ -139,7 +139,10 @@ static int vrrp_ndisc_una_build(struct interface *ifp, struct ipaddr *ip,
ph.dst = ip6h->ip6_dst;
ph.ulpl = htonl(len);
ph.next_hdr = IPPROTO_ICMPV6;
- icmp6h->icmp6_cksum = in_cksum_with_ph6(&ph, (void *)icmp6h, len);
+
+ /* Suppress static analysis warnings about accessing icmp6 oob */
+ void *offset = icmp6h;
+ icmp6h->icmp6_cksum = in_cksum_with_ph6(&ph, offset, len);
return 0;
}