[dpdk-dev] [PATCH v2 3/4] examples/mp_server: fix snprintf overflow

Nicolau, Radu radu.nicolau at intel.com
Fri Oct 9 13:22:27 CEST 2020


On 8/21/2020 6:10 PM, Bruce Richardson wrote:
> When producing a printable mac address the buffer was appropriately sized
> for holding the mac address exactly, but the actual snprintf included a
> '\n' character at the end, which means that the snprintf technically is
> getting truncated i.e. the \n would not be added due to lack of space.
> This gets flagged as a problem by modern versions of gcc, e.g. on Ubuntu
> 20.04.
>
> main.c:77:37: warning: ‘__builtin___snprintf_chk’ output truncated before the last format character [-Wformat-truncation=]
>     77 |     "%02x:%02x:%02x:%02x:%02x:%02x\n",
>        |                                     ^
>
> Since the \n is getting stripped anyway, we can fix the issue by just
> removing it. In the process we can switch to using the standard ethernet
> address formating function from rte_ether.h.
>
> Fixes: af75078fece3 ("first public release")
> Cc: stable at dpdk.org
> Cc: Stephen Hemminger <stephen at networkplumber.org>
>
> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
>
> ---
> V2: switched code to use standard formatting function
> ---

Acked-by: Radu Nicolau <radu.nicolau at intel.com>



More information about the dev mailing list