fib: fix unitialized padding in fib_api_next_hop_decode 41/33941/2
authorBenoît Ganne <bganne@cisco.com>
Fri, 1 Oct 2021 17:20:02 +0000 (19:20 +0200)
committerNeale Ranns <neale@graphiant.com>
Mon, 4 Oct 2021 12:48:40 +0000 (12:48 +0000)
If the type is IPv4, makes sure the padding bytes are set to 0 as this
is used by ip46_address_is_ip4() to detect the type.

Type: fix

Change-Id: I6a81fa05a6b227086853901bf3dcdc66e6d04d2c
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vnet/fib/fib_api.c

index 0254c55..3ccb9ca 100644 (file)
@@ -65,10 +65,8 @@ static void
 fib_api_next_hop_decode (const vl_api_fib_path_t *in,
                          ip46_address_t *out)
 {
-    if (in->proto == FIB_API_PATH_NH_PROTO_IP4)
-        clib_memcpy (&out->ip4, &in->nh.address.ip4, sizeof (out->ip4));
-    else if (in->proto == FIB_API_PATH_NH_PROTO_IP6)
-        clib_memcpy (&out->ip6, &in->nh.address.ip6, sizeof (out->ip6));
+    ASSERT (FIB_API_PATH_NH_PROTO_IP4 == in->proto || FIB_API_PATH_NH_PROTO_IP6 == in->proto);
+    *out = to_ip46 (FIB_API_PATH_NH_PROTO_IP6 == in->proto, (void *)&in->nh.address);
 }
 
 static vl_api_fib_path_nh_proto_t