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 3B4AAA04B0 for ; Fri, 21 Aug 2020 19:10:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F56D1C0C4; Fri, 21 Aug 2020 19:10:56 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id B83781C0BC; Fri, 21 Aug 2020 19:10:53 +0200 (CEST) IronPort-SDR: l6apqZrP5iVjPetj314lee6ZN9wIRLLTOafyI821K4JDWLEis5Yl7FLIQvINrzqLrrUKn31efd lEYUn95f3OeQ== X-IronPort-AV: E=McAfee;i="6000,8403,9720"; a="152998904" X-IronPort-AV: E=Sophos;i="5.76,338,1592895600"; d="scan'208";a="152998904" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2020 10:10:52 -0700 IronPort-SDR: nOS2YkSF/ABPJ59OmAbEnHQgt5v5cpfRrbdqIRx4y+HkBMnob0mmW8JPiTwLhmQHQLd2G7X0bK m+htoLvYFh+g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,338,1592895600"; d="scan'208";a="498037788" Received: from silpixa00399126.ir.intel.com ([10.237.222.56]) by fmsmga006.fm.intel.com with ESMTP; 21 Aug 2020 10:10:51 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, David Hunt , Pablo de Lara , Alan Carew Date: Fri, 21 Aug 2020 18:10:15 +0100 Message-Id: <20200821171017.50531-3-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821171017.50531-1-bruce.richardson@intel.com> References: <20200814110045.217724-1-bruce.richardson@intel.com> <20200821171017.50531-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [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" 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); -- 2.25.1