yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
255e5e
From ab9c1c0d86b35fb159a6c173134e4ae816f130f3 Mon Sep 17 00:00:00 2001
255e5e
From: jmaloy <jmaloy@redhat.com>
255e5e
Date: Thu, 14 May 2020 21:13:12 +0100
255e5e
Subject: [PATCH 4/6] tftp: use slirp_fmt0()
255e5e
MIME-Version: 1.0
255e5e
Content-Type: text/plain; charset=UTF-8
255e5e
Content-Transfer-Encoding: 8bit
255e5e
255e5e
RH-Author: jmaloy <jmaloy@redhat.com>
255e5e
Message-id: <20200514211314.1534001-5-jmaloy@redhat.com>
255e5e
Patchwork-id: 96588
255e5e
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 4/6] tftp: use slirp_fmt0()
255e5e
Bugzilla: 1834477
255e5e
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
255e5e
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
255e5e
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
255e5e
255e5e
From: Marc-André Lureau <marcandre.lureau@redhat.com>
255e5e
255e5e
Make it OOB-safe, warn on truncation, always \0-end, abort on error.
255e5e
255e5e
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
255e5e
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
255e5e
Message-Id: <20200127092414.169796-5-marcandre.lureau@redhat.com>
255e5e
255e5e
(cherry picked from libslirp commit 98968c4f94330b3e4fe48dc79a851eff5e8a5962)
255e5e
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
255e5e
255e5e
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
255e5e
---
255e5e
 slirp/tftp.c | 6 ++----
255e5e
 1 file changed, 2 insertions(+), 4 deletions(-)
255e5e
255e5e
diff --git a/slirp/tftp.c b/slirp/tftp.c
255e5e
index a9bc4bb..c3a2ce6 100644
255e5e
--- a/slirp/tftp.c
255e5e
+++ b/slirp/tftp.c
255e5e
@@ -184,10 +184,8 @@ static int tftp_send_oack(struct tftp_session *spt,
255e5e
 
255e5e
     tp->tp_op = htons(TFTP_OACK);
255e5e
     for (i = 0; i < nb; i++) {
255e5e
-        n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s",
255e5e
-                      keys[i]) + 1;
255e5e
-        n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u",
255e5e
-                      values[i]) + 1;
255e5e
+        n += slirp_fmt0(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s", keys[i]);
255e5e
+        n += slirp_fmt0(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u", values[i]);
255e5e
     }
255e5e
 
255e5e
     m->m_len = sizeof(struct tftp_t) - (TFTP_BLOCKSIZE_MAX + 2) + n
255e5e
-- 
255e5e
1.8.3.1
255e5e