[Slirp] [PATCH 5/6] tcp_ctl: use slirp_fmt()

Philippe Mathieu-Daudé philmd at redhat.com
Mon Jan 27 09:46:40 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 safer to OOB (sb_cc must not go out of sb_data), warn on
> truncation, 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/tcp_subr.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/src/tcp_subr.c b/src/tcp_subr.c
> index 7832b14..a699117 100644
> --- a/src/tcp_subr.c
> +++ b/src/tcp_subr.c
> @@ -965,9 +965,8 @@ int tcp_ctl(struct socket *so)
>               }
>           }
>       }
> -    sb->sb_cc =
> -        snprintf(sb->sb_wptr, sb->sb_datalen - (sb->sb_wptr - sb->sb_data),
> -                 "Error: No application configured.\r\n");
> +    sb->sb_cc = slirp_fmt(sb->sb_wptr, sb->sb_datalen - (sb->sb_wptr - sb->sb_data),
> +                          "Error: No application configured.\r\n");
>       sb->sb_wptr += sb->sb_cc;
>       return 0;
>   }
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd at redhat.com>



More information about the Slirp mailing list