diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-01-27 10:24:12 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-01-27 10:28:43 +0100 |
commit | 98968c4f94330b3e4fe48dc79a851eff5e8a5962 (patch) | |
tree | e9c5de70162ed303c870a453c831b0c00e5a9a91 /src | |
parent | 2af8a28a7ef0acde6f7525b346a3701d1cb54cd8 (diff) | |
download | slirp-98968c4f94330b3e4fe48dc79a851eff5e8a5962.zip slirp-98968c4f94330b3e4fe48dc79a851eff5e8a5962.tar.gz slirp-98968c4f94330b3e4fe48dc79a851eff5e8a5962.tar.bz2 |
tftp: use slirp_fmt0()
Make it OOB-safe, warn on truncation, always \0-end, abort on error.
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Message-Id: <20200127092414.169796-5-marcandre.lureau@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/tftp.c | 8 |
1 files changed, 2 insertions, 6 deletions
@@ -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; |