From d031facefbadc6c3f1ddb185c8e965cce68914e8 Mon Sep 17 00:00:00 2001 From: jmaloy Date: Thu, 14 May 2020 21:13:11 +0100 Subject: [PATCH 3/6] misc: use slirp_fmt0() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: jmaloy Message-id: <20200514211314.1534001-4-jmaloy@redhat.com> Patchwork-id: 96587 O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 3/6] misc: use slirp_fmt0() Bugzilla: 1834477 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Stefano Garzarella RH-Acked-by: Kevin Wolf From: Marc-André Lureau Those are safe and should never fail. Nevertheless, use slirp_snfillf0() for more safety. Signed-off-by: Marc-André Lureau Reviewed-by: Samuel Thibault Message-Id: <20200127092414.169796-4-marcandre.lureau@redhat.com> (cherry picked from libslirp commit 2af8a28a7ef0acde6f7525b346a3701d1cb54cd8) Signed-off-by: Jon Maloy Signed-off-by: Danilo C. L. de Paula --- slirp/misc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/slirp/misc.c b/slirp/misc.c index 035b9ab..e256dbe 100644 --- a/slirp/misc.c +++ b/slirp/misc.c @@ -250,7 +250,7 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) dst_addr = so->so_faddr; dst_port = so->so_fport; } - snprintf(buf, sizeof(buf), " TCP[%s]", state); + slirp_fmt0(buf, sizeof(buf), " TCP[%s]", state); monitor_printf(mon, "%-19s %3d %15s %5d ", buf, so->s, src.sin_addr.s_addr ? inet_ntoa(src.sin_addr) : "*", ntohs(src.sin_port)); @@ -261,14 +261,14 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) for (so = slirp->udb.so_next; so != &slirp->udb; so = so->so_next) { if (so->so_state & SS_HOSTFWD) { - snprintf(buf, sizeof(buf), " UDP[HOST_FORWARD]"); + slirp_fmt0(buf, sizeof(buf), " UDP[HOST_FORWARD]"); src_len = sizeof(src); getsockname(so->s, (struct sockaddr *)&src, &src_len); dst_addr = so->so_laddr; dst_port = so->so_lport; } else { - snprintf(buf, sizeof(buf), " UDP[%d sec]", - (so->so_expire - curtime) / 1000); + slirp_fmt0(buf, sizeof(buf), " UDP[%d sec]", + (so->so_expire - curtime) / 1000); src.sin_addr = so->so_laddr; src.sin_port = so->so_lport; dst_addr = so->so_faddr; @@ -283,8 +283,8 @@ void slirp_connection_info(Slirp *slirp, Monitor *mon) } for (so = slirp->icmp.so_next; so != &slirp->icmp; so = so->so_next) { - snprintf(buf, sizeof(buf), " ICMP[%d sec]", - (so->so_expire - curtime) / 1000); + slirp_fmt0(buf, sizeof(buf), " ICMP[%d sec]", + (so->so_expire - curtime) / 1000); src.sin_addr = so->so_laddr; dst_addr = so->so_faddr; monitor_printf(mon, "%-19s %3d %15s - ", buf, so->s, -- 1.8.3.1