tap: do not use strlen on vector 42/28942/3
authorVladimir Isaev <visaev@netgate.com>
Fri, 18 Sep 2020 11:43:29 +0000 (14:43 +0300)
committerBeno�t Ganne <bganne@cisco.com>
Fri, 18 Sep 2020 14:57:04 +0000 (14:57 +0000)
sanitizer complains about strlen on hi->name in tap_dump_ifs.
hi->name is a vector which is not null-terminated, so use vec_len.

Type: fix
Signed-off-by: Vladimir Isaev <visaev@netgate.com>
Change-Id: Icdd5f65369bb51b0c4a9cd86c24899e6febd837c

src/vnet/devices/tap/tap.c

index c265aa2..77c15ce 100644 (file)
@@ -946,8 +946,7 @@ tap_dump_ifs (tap_interface_details_t ** out_tapids)
     tapid->sw_if_index = vif->sw_if_index;
     hi = vnet_get_hw_interface (vnm, vif->hw_if_index);
     clib_memcpy(tapid->dev_name, hi->name,
-                MIN (ARRAY_LEN (tapid->dev_name) - 1,
-                     strlen ((const char *) hi->name)));
+                MIN (ARRAY_LEN (tapid->dev_name) - 1, vec_len (hi->name)));
     vring = vec_elt_at_index (vif->rxq_vrings, RX_QUEUE_ACCESS(0));
     tapid->rx_ring_sz = vring->size;
     vring = vec_elt_at_index (vif->txq_vrings, TX_QUEUE_ACCESS(0));