From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9D23C388F7 for ; Wed, 28 Oct 2020 16:27:35 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id E9BE1247B6 for ; Wed, 28 Oct 2020 16:27:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E9BE1247B6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D431D9B04; Wed, 28 Oct 2020 17:27:23 +0100 (CET) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 81DBE72E2; Wed, 28 Oct 2020 17:27:20 +0100 (CET) IronPort-SDR: rl8R4IzT4TUG7Ar+Saq8u4sfk3NQqIVyYcNSsGnLIlJDKiMddaKH2Bq1DGZIbEq0/EUYBQZuPT btR4PekapzIA== X-IronPort-AV: E=McAfee;i="6000,8403,9788"; a="165699131" X-IronPort-AV: E=Sophos;i="5.77,427,1596524400"; d="scan'208";a="165699131" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Oct 2020 09:27:18 -0700 IronPort-SDR: kjaueFKv8qv5y1kdMOPzRwUG+GazdrkIO8T8NSKG9mNw+cQSeYPgoDgdINSGAVzaWcXekEDyYn flRPDSLlLHMg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,427,1596524400"; d="scan'208";a="334787959" Received: from silpixa00399126.ir.intel.com ([10.237.222.4]) by orsmga002.jf.intel.com with ESMTP; 28 Oct 2020 09:27:16 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, David Hunt , Alan Carew , Pablo de Lara Date: Wed, 28 Oct 2020 16:27:00 +0000 Message-Id: <20201028162702.969509-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201028162702.969509-1-bruce.richardson@intel.com> References: <20200814110045.217724-1-bruce.richardson@intel.com> <20201028162702.969509-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 1/3] examples/vm_power_manager: fix string truncation warning X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Acked-by: David Hunt --- 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 74a2a677e..a26315051 100644 --- a/examples/vm_power_manager/channel_manager.c +++ b/examples/vm_power_manager/channel_manager.c @@ -467,9 +467,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