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 4DBC5A04B0 for ; Fri, 14 Aug 2020 13:01:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C18781C10A; Fri, 14 Aug 2020 13:01:25 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 55B0D1C10A; Fri, 14 Aug 2020 13:01:24 +0200 (CEST) IronPort-SDR: 0Bnajj8OL0HQP5mfr95Nt+RGX1IDRg0kzJZKsoNKkyBZ9+g+Vk2+spDXza4FSP7R69bcbsivb6 3hjKL6O5E2DA== X-IronPort-AV: E=McAfee;i="6000,8403,9712"; a="215912182" X-IronPort-AV: E=Sophos;i="5.76,312,1592895600"; d="scan'208";a="215912182" 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; 14 Aug 2020 04:01:23 -0700 IronPort-SDR: n7e97rRV1U+qcowaYSJEdEc/QhqTUqmDoEs5X3+CQ6nDeTiRrkRkJ8l8hPmz+vFaOvp2bSIQgG 8UtyiyyI/dDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.76,312,1592895600"; d="scan'208";a="470553543" Received: from silpixa00399126.ir.intel.com ([10.237.222.56]) by orsmga005.jf.intel.com with ESMTP; 14 Aug 2020 04:01:22 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , stable@dpdk.org, Anatoly Burakov Date: Fri, 14 Aug 2020 12:00:44 +0100 Message-Id: <20200814110045.217724-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200814110045.217724-1-bruce.richardson@intel.com> References: <20200814110045.217724-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] [PATCH 3/4] examples/mp_server: fix snprintf overflow 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 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 --- 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]); } -- 2.25.1