From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 65990A04B2 for ; Wed, 26 Aug 2020 12:10:02 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4F78B14583; Wed, 26 Aug 2020 12:10:02 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id EAD63255; Wed, 26 Aug 2020 12:09:58 +0200 (CEST) IronPort-SDR: x+gR8ADOKmDxEqLoYLMieIzLwr4Xk69fUh5MWmmPJScyyJIVqirTWj7z6q7MGXj4ik7ZNt2Tsx oUoei1vYls7Q== X-IronPort-AV: E=McAfee;i="6000,8403,9724"; a="217812496" X-IronPort-AV: E=Sophos;i="5.76,355,1592895600"; d="scan'208";a="217812496" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 03:09:57 -0700 IronPort-SDR: 4jCe2RXtc+mWHQSeO67vS0Ax/YY+HGJnCS1v7MlHMJN/MkzlgTcSETWdkomwelf3Q6Ho7ZO4cO 5lRqKTYrA7sQ== X-IronPort-AV: E=Sophos;i="5.76,355,1592895600"; d="scan'208";a="474716500" Received: from dhunt5-mobl5.ger.corp.intel.com (HELO [10.213.235.135]) ([10.213.235.135]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Aug 2020 03:09:55 -0700 To: Bruce Richardson , dev@dpdk.org Cc: stable@dpdk.org, Pablo de Lara , Alan Carew References: <20200814110045.217724-1-bruce.richardson@intel.com> <20200821171017.50531-1-bruce.richardson@intel.com> <20200821171017.50531-3-bruce.richardson@intel.com> From: David Hunt Message-ID: <4499ace4-1162-7f71-426e-5b42f58aa86c@intel.com> Date: Wed, 26 Aug 2020 11:09:53 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.0 MIME-Version: 1.0 In-Reply-To: <20200821171017.50531-3-bruce.richardson@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [dpdk-stable] [PATCH v2 2/4] examples/vm_power_manager: fix string truncation warning X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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 > --- > 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