[Slirp] [PATCH 4/6] tftp: use slirp_fmt0()
Philippe Mathieu-Daudé
philmd at redhat.com
Mon Jan 27 09:46:10 UTC 2020
On 1/27/20 10:24 AM, marcandre.lureau at redhat.com wrote:
> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>
> Make it OOB-safe, warn on truncation, always \0-end, abort on error.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
> Reviewed-by: Samuel Thibault <samuel.thibault at ens-lyon.org>
> ---
> src/tftp.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> 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;
>
Reviewed-by: Philippe Mathieu-Daudé <philmd at redhat.com>
More information about the Slirp
mailing list