Blob Blame History Raw
From d031facefbadc6c3f1ddb185c8e965cce68914e8 Mon Sep 17 00:00:00 2001
From: jmaloy <jmaloy@redhat.com>
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 <jmaloy@redhat.com>
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 <stefanha@redhat.com>
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Those are safe and should never fail. Nevertheless, use
slirp_snfillf0() for more safety.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-Id: <20200127092414.169796-4-marcandre.lureau@redhat.com>

(cherry picked from libslirp commit 2af8a28a7ef0acde6f7525b346a3701d1cb54cd8)
Signed-off-by: Jon Maloy <jmaloy@redhat.com>

Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
 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