From 98968c4f94330b3e4fe48dc79a851eff5e8a5962 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 27 Jan 2020 10:24:12 +0100 Subject: tftp: use slirp_fmt0() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make it OOB-safe, warn on truncation, always \0-end, abort on error. Signed-off-by: Marc-André Lureau Reviewed-by: Samuel Thibault Message-Id: <20200127092414.169796-5-marcandre.lureau@redhat.com> --- src/tftp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/tftp.c b/src/tftp.c index 4d9ee1f..c209145 100644 --- a/src/tftp.c +++ b/src/tftp.c @@ -185,12 +185,8 @@ static int tftp_send_oack(struct tftp_session *spt, const char *keys[], tp->tp_op = htons(TFTP_OACK); for (i = 0; i < nb; i++) { - n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s", - keys[i]) + - 1; - n += snprintf(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u", - values[i]) + - 1; + n += slirp_fmt0(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%s", keys[i]); + n += slirp_fmt0(tp->x.tp_buf + n, sizeof(tp->x.tp_buf) - n, "%u", values[i]); } m->m_len = G_SIZEOF_MEMBER(struct tftp_t, tp_op) + n; -- cgit v1.1