DPDK patches and discussions
 help / color / mirror / Atom feed
From: David Hunt <david.hunt@intel.com>
To: Bruce Richardson <bruce.richardson@intel.com>, dev@dpdk.org
Cc: stable@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>,
	Alan Carew <alan.carew@intel.com>
Subject: Re: [dpdk-dev] [PATCH v2 2/4] examples/vm_power_manager: fix string truncation warning
Date: Wed, 26 Aug 2020 11:09:53 +0100
Message-ID: <4499ace4-1162-7f71-426e-5b42f58aa86c@intel.com> (raw)
In-Reply-To: <20200821171017.50531-3-bruce.richardson@intel.com>

Hi Bruce,

On 21/8/2020 6:10 PM, Bruce Richardson wrote:
> When compiling on ubuntu 20.04, a warning was issued about possible
> truncation of the path string for the power management socket.
>
> channel_manager.c: In function ‘add_all_channels’:
> channel_manager.c:470:41: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 90 [-Wformat-truncation=]
>    470 |     sizeof(chan_info->channel_path), "%s%s",
>        |                                         ^~
>
> This can be fixed by adding in an explicit truncation check to the code and
> handling it appropriately.
>
> Fixes: e8ae9b662506 ("examples/vm_power: channel manager and monitor in host")
> Cc: stable@dpdk.org
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>   examples/vm_power_manager/channel_manager.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/examples/vm_power_manager/channel_manager.c b/examples/vm_power_manager/channel_manager.c
> index 3da01b46d8..0a28cb643b 100644
> --- a/examples/vm_power_manager/channel_manager.c
> +++ b/examples/vm_power_manager/channel_manager.c
> @@ -466,9 +466,15 @@ add_all_channels(const char *vm_name)
>   			continue;
>   		}
>   
> -		snprintf(chan_info->channel_path,
> +		if ((size_t)snprintf(chan_info->channel_path,
>   				sizeof(chan_info->channel_path), "%s%s",
> -				CHANNEL_MGR_SOCKET_PATH, dir->d_name);
> +				CHANNEL_MGR_SOCKET_PATH, dir->d_name)
> +					>= sizeof(chan_info->channel_path)) {
> +			RTE_LOG(ERR, CHANNEL_MANAGER, "Pathname too long for channel '%s%s'\n",
> +					CHANNEL_MGR_SOCKET_PATH, dir->d_name);
> +			rte_free(chan_info);
> +			continue;
> +		}
>   
>   		if (setup_channel_info(&vm_info, &chan_info, channel_num) < 0) {
>   			rte_free(chan_info);


Acked-by: David Hunt <david.hunt@intel.com>



  reply	other threads:[~2020-08-26 10:10 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
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 [this message]
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=4499ace4-1162-7f71-426e-5b42f58aa86c@intel.com \
    --to=david.hunt@intel.com \
    --cc=alan.carew@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=pablo.de.lara.guarch@intel.com \
    --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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git