ping: Fix coverity error 163907 70/5770/2
authorAndrew Yourtchenko <ayourtch@gmail.com>
Thu, 16 Mar 2017 12:24:24 +0000 (12:24 +0000)
committerOle Trøan <otroan@employees.org>
Thu, 16 Mar 2017 15:15:34 +0000 (15:15 +0000)
Return an error if the ip6_interface_first_address decides to return NULL.

Change-Id: Iea0184382b8fbe2af81a781c3671687a1fbb5b32
Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
src/vnet/ip/ping.c
src/vnet/ip/ping.h

index e4f2ee7..a2b96ab 100644 (file)
@@ -307,6 +307,11 @@ send_ip6_ping (vlib_main_t * vm, ip6_main_t * im,
 
   /* Fill in the correct source now */
   ip6_address_t *a = ip6_interface_first_address (im, sw_if_index);
+  if (!a)
+    {
+      vlib_buffer_free (vm, &bi0, 1);
+      return SEND_PING_NO_SRC_ADDRESS;
+    }
   h0->ip6.src_address = a[0];
 
   /* Fill in icmp fields */
index 1887314..0af9d58 100644 (file)
@@ -32,6 +32,7 @@ typedef enum
   SEND_PING_ALLOC_FAIL,
   SEND_PING_NO_INTERFACE,
   SEND_PING_NO_TABLE,
+  SEND_PING_NO_SRC_ADDRESS,
 } send_ip46_ping_result_t;
 
 /*