DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org, stable@dpdk.org,
	Anatoly Burakov <anatoly.burakov@intel.com>
Subject: Re: [dpdk-dev] [PATCH 3/4] examples/mp_server: fix snprintf overflow
Date: Fri, 14 Aug 2020 08:01:16 -0700	[thread overview]
Message-ID: <20200814080116.37da0f89@hermes.lan> (raw)
In-Reply-To: <20200814110045.217724-4-bruce.richardson@intel.com>

On Fri, 14 Aug 2020 12:00:44 +0100
Bruce Richardson <bruce.richardson@intel.com> 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 from the printf string.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  examples/multi_process/client_server_mp/mp_server/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
> index 280dab8672..af5af672c3 100644
> --- a/examples/multi_process/client_server_mp/mp_server/main.c
> +++ b/examples/multi_process/client_server_mp/mp_server/main.c
> @@ -74,7 +74,7 @@ get_printable_mac_addr(uint16_t port)
>  			return err_address;
>  		}
>  		snprintf(addresses[port], sizeof(addresses[port]),
> -				"%02x:%02x:%02x:%02x:%02x:%02x\n",
> +				"%02x:%02x:%02x:%02x:%02x:%02x",
>  				mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2],
>  				mac.addr_bytes[3], mac.addr_bytes[4], mac.addr_bytes[5]);
>  	}

Please convert to rte_ether_format_addr() instead of local hard coded format.

  reply	other threads:[~2020-08-14 15:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-14 11:00 [dpdk-dev] [PATCH 0/4] fixes for example app builds Bruce Richardson
2020-08-14 11:00 ` [dpdk-dev] [PATCH 1/4] power: make guest channel headers public Bruce Richardson
2020-08-14 11:05   ` Bruce Richardson
2020-08-14 11:00 ` [dpdk-dev] [PATCH 2/4] examples/vm_power_manager: fix string truncation warning Bruce Richardson
2020-08-14 11:00 ` [dpdk-dev] [PATCH 3/4] examples/mp_server: fix snprintf overflow Bruce Richardson
2020-08-14 15:01   ` Stephen Hemminger [this message]
2020-08-14 11:00 ` [dpdk-dev] [PATCH 4/4] examples/mp_server: clear string truncation warning Bruce Richardson
2020-08-21 17:10 ` [dpdk-dev] [PATCH v2 0/4] fixes for example app builds Bruce Richardson
2020-08-21 17:10   ` [dpdk-dev] [PATCH v2 1/4] power: make guest channel headers public Bruce Richardson
2020-08-26 10:08     ` David Hunt
2020-10-05 21:44     ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2020-08-21 17:10   ` [dpdk-dev] [PATCH v2 2/4] examples/vm_power_manager: fix string truncation warning Bruce Richardson
2020-08-26 10:09     ` David Hunt
2020-08-21 17:10   ` [dpdk-dev] [PATCH v2 3/4] examples/mp_server: fix snprintf overflow Bruce Richardson
2020-10-09 11:22     ` Nicolau, Radu
2020-08-21 17:10   ` [dpdk-dev] [PATCH v2 4/4] examples/mp_server: clear string truncation warning Bruce Richardson
2020-10-09 11:21     ` Nicolau, Radu
2020-10-28 16:26 ` [dpdk-dev] [PATCH v3 0/3] fixes for example app builds Bruce Richardson
2020-10-28 16:27   ` [dpdk-dev] [PATCH v3 1/3] examples/vm_power_manager: fix string truncation warning Bruce Richardson
2020-10-28 16:27   ` [dpdk-dev] [PATCH v3 2/3] examples/mp_server: fix snprintf overflow Bruce Richardson
2020-10-28 16:27   ` [dpdk-dev] [PATCH v3 3/3] examples/mp_server: clear string truncation warning Bruce Richardson
2020-10-30 13:56   ` [dpdk-dev] [PATCH v3 0/3] fixes for example app builds David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200814080116.37da0f89@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=anatoly.burakov@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).