summaryrefslogtreecommitdiffstats
path: root/src/plugins/vrrp/vrrp_packet.c
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2020-02-20 08:58:15 -0600
committerNeale Ranns <nranns@cisco.com>2020-02-21 08:53:57 +0000
commit269549491ae6c8d9c35d6b4fa9441ad15e6b82f0 (patch)
treeec571573c70a1607c03d99f8a5fbb7d77e1fc591 /src/plugins/vrrp/vrrp_packet.c
parent62a7fe28933b6310b9a4e3a0fab99949587576ac (diff)
vrrp: fix coverity errors
Type: fix Fixes: 39e9428b90 Fix warnings about potential problems with an implicit type cast and a null pointer dereference. Change-Id: I8c8d220e79ba45b62ba783cfe53cb49eef175fc8 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Diffstat (limited to 'src/plugins/vrrp/vrrp_packet.c')
-rw-r--r--src/plugins/vrrp/vrrp_packet.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/vrrp/vrrp_packet.c b/src/plugins/vrrp/vrrp_packet.c
index f624b1876c3..6b0d4c96c2d 100644
--- a/src/plugins/vrrp/vrrp_packet.c
+++ b/src/plugins/vrrp/vrrp_packet.c
@@ -282,6 +282,16 @@ vrrp_adv_send (vrrp_vr_t * vr, int shutdown)
if (is_unicast)
n_buffers = vec_len (vr->config.peer_addrs);
+ if (n_buffers < 1)
+ {
+ /* A unicast VR will not start without peers added so this should
+ * not happen. Just avoiding a crash if it happened somehow.
+ */
+ clib_warning ("Unicast VR configuration corrupted for %U",
+ format_vrrp_vr_key, vr);
+ return -1;
+ }
+
vec_validate (bi, n_buffers - 1);
if (vlib_buffer_alloc (vm, bi, n_buffers) != n_buffers)
{