From 07007a43513817859d0c0b50c21a96221aa101e4 Mon Sep 17 00:00:00 2001
From: jmaloy <jmaloy@redhat.com>
Date: Thu, 14 May 2020 21:13:10 +0100
Subject: [PATCH 2/6] dhcpv6: use slirp_fmt()
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-3-jmaloy@redhat.com>
Patchwork-id: 96586
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH v2 2/6] dhcpv6: use slirp_fmt()
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>
Warn if result is truncated, return bytes actually written (excluding \0).
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-Id: <20200127092414.169796-3-marcandre.lureau@redhat.com>
(cherry picked from libslirp commit f207a7cee35a584d8ecd4b852cb238fb5d743c85)
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
slirp/dhcpv6.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/slirp/dhcpv6.c b/slirp/dhcpv6.c
index d266611..1ee6176 100644
--- a/slirp/dhcpv6.c
+++ b/slirp/dhcpv6.c
@@ -162,13 +162,12 @@ static void dhcpv6_info_request(Slirp *slirp, struct sockaddr_in6 *srcsas,
*resp++ = OPTION_BOOTFILE_URL >> 8; /* option-code high byte */
*resp++ = OPTION_BOOTFILE_URL; /* option-code low byte */
smaxlen = (uint8_t *)m->m_data + IF_MTU - (resp + 2);
- slen = snprintf((char *)resp + 2, smaxlen,
- "tftp://[%02x%02x:%02x%02x:%02x%02x:%02x%02x:"
- "%02x%02x:%02x%02x:%02x%02x:%02x%02x]/%s",
- sa[0], sa[1], sa[2], sa[3], sa[4], sa[5], sa[6], sa[7],
- sa[8], sa[9], sa[10], sa[11], sa[12], sa[13], sa[14],
- sa[15], slirp->bootp_filename);
- slen = MIN(slen, smaxlen);
+ slen = slirp_fmt((char *)resp + 2, smaxlen,
+ "tftp://[%02x%02x:%02x%02x:%02x%02x:%02x%02x:"
+ "%02x%02x:%02x%02x:%02x%02x:%02x%02x]/%s",
+ sa[0], sa[1], sa[2], sa[3], sa[4], sa[5], sa[6], sa[7],
+ sa[8], sa[9], sa[10], sa[11], sa[12], sa[13], sa[14],
+ sa[15], slirp->bootp_filename);
*resp++ = slen >> 8; /* option-len high byte */
*resp++ = slen; /* option-len low byte */
resp += slen;
--
1.8.3.1