From 6dc526114733f69907752e3627b11aa4201be240 Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Fri, 2 Aug 2019 15:44:43 +0000 Subject: [PATCH] fix(userspace/libsinsp): constraint printing of iface info (name, address, etc.) Signed-off-by: Leonardo Di Donato --- userspace/libsinsp/ifinfo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/userspace/libsinsp/ifinfo.cpp b/userspace/libsinsp/ifinfo.cpp index 5c3e34cde0..ff84c4928e 100644 --- a/userspace/libsinsp/ifinfo.cpp +++ b/userspace/libsinsp/ifinfo.cpp @@ -40,8 +40,8 @@ sinsp_ipv4_ifinfo::sinsp_ipv4_ifinfo(uint32_t addr, uint32_t netmask, uint32_t b void sinsp_ipv4_ifinfo::convert_to_string(char * dest, const uint32_t addr) { sprintf( - dest, - "%d.%d.%d.%d", + dest, + "%d.%d.%d.%d", (addr & 0xFF), ((addr & 0xFF00) >> 8), ((addr & 0xFF0000) >> 16), @@ -65,7 +65,7 @@ string sinsp_ipv4_ifinfo::to_string() const convert_to_string(str_addr, m_addr); convert_to_string(s_netmask, m_netmask); convert_to_string(s_bcast, m_bcast); - sprintf(s, "%s inet %s netmask %s broadcast %s", m_name.c_str(), str_addr, s_netmask, s_bcast); + snprintf(s, sizeof(s), "%s inet %s netmask %s broadcast %s", m_name.c_str(), str_addr, s_netmask, s_bcast); return string(s); } @@ -230,7 +230,7 @@ bool sinsp_network_interfaces::is_ipv4addr_in_local_machine(uint32_t addr, sinsp // // Note: if we don't have container info, any pick we make is arbitrary. - // To at least achieve consistency across client and server, we just match the host interface addresses. + // To at least achieve consistency across client and server, we just match the host interface addresses. // if(container_info) {