From adbaf7bc2e301e591d63fae47f0a9bbb1577494e Mon Sep 17 00:00:00 2001 From: Benoît Ganne Date: Wed, 10 Jul 2019 15:40:33 +0200 Subject: ip: fix show ip neigh vector read overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both format_ethernet_arp_ip4_entry() and format_ip6_neighbor_ip6_entry() used %s to format flags which is a vector and not a null-terminated C-string. Introduce format_ip_neighbor_flags() instead. Type: fix Fixes: 102ec52bc4 Change-Id: I0c9349fefbeb76471933de358acceb50512a21aa Signed-off-by: Benoît Ganne --- src/vnet/ip/ip_neighbor.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/vnet/ip/ip_neighbor.c') diff --git a/src/vnet/ip/ip_neighbor.c b/src/vnet/ip/ip_neighbor.c index ad89d3ff679..bd0144101ed 100644 --- a/src/vnet/ip/ip_neighbor.c +++ b/src/vnet/ip/ip_neighbor.c @@ -47,6 +47,23 @@ typedef struct static ip_neighbor_scan_config_t ip_neighbor_scan_conf; +u8 * +format_ip_neighbor_flags (u8 * s, va_list * args) +{ + const ip_neighbor_flags_t flags = va_arg (*args, int); + + if (flags & IP_NEIGHBOR_FLAG_STATIC) + s = format (s, "S"); + + if (flags & IP_NEIGHBOR_FLAG_DYNAMIC) + s = format (s, "D"); + + if (flags & IP_NEIGHBOR_FLAG_NO_FIB_ENTRY) + s = format (s, "N"); + + return s; +} + int ip_neighbor_add (const ip46_address_t * ip, ip46_type_t type, -- cgit 1.2.3-korg