From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 972802C18 for ; Tue, 20 Mar 2018 09:51:53 +0100 (CET) Received: from core.dev.6wind.com (unknown [10.0.0.1]) by proxy.6wind.com (Postfix) with ESMTPS id 864B014B294; Tue, 20 Mar 2018 09:47:25 +0100 (CET) Received: from [10.16.0.195] (helo=6wind.com) by core.dev.6wind.com with smtp (Exim 4.84_2) (envelope-from ) id 1eyCzc-0000f8-1K; Tue, 20 Mar 2018 09:51:41 +0100 Received: by 6wind.com (sSMTP sendmail emulation); Tue, 20 Mar 2018 09:51:40 +0100 Date: Tue, 20 Mar 2018 09:51:39 +0100 From: Olivier Matz To: Stephen Hemminger Cc: dev@dpdk.org Message-ID: <20180320085139.lqtalez36nri52or@glumotte.dev.6wind.com> References: <20180319175213.9360-1-stephen@networkplumber.org> <20180319175213.9360-2-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180319175213.9360-2-stephen@networkplumber.org> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH 1/2] rte_mempool: fix strncpy warnings 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: , X-List-Received-Date: Tue, 20 Mar 2018 08:51:54 -0000 Hi Stephen, On Mon, Mar 19, 2018 at 10:52:12AM -0700, Stephen Hemminger wrote: > [dpdk-dev] [PATCH 1/2] rte_mempool: fix strncpy warnings The title should be prefixed by "mbuf:" instead of "rte_mempool:" > Gcc-8 discovers issue with platform_mempool_ops. > rte_mbuf_pool_ops.c:26:3: error: ‘strncpy’ output truncated before > terminating nul copying as many bytes from a string as its length > [-Werror=stringop-truncation] > strncpy(mz->addr, ops_name, strlen(ops_name)); > > The issue is that the size should be size in destination not source. > > Fixes: a3acc3144a76 ("mbuf: add pool ops selection functions") > --- > lib/librte_mbuf/rte_mbuf_pool_ops.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_mbuf/rte_mbuf_pool_ops.c b/lib/librte_mbuf/rte_mbuf_pool_ops.c > index 48cc342002a5..661cf4fb401f 100644 > --- a/lib/librte_mbuf/rte_mbuf_pool_ops.c > +++ b/lib/librte_mbuf/rte_mbuf_pool_ops.c > @@ -23,7 +23,7 @@ rte_mbuf_set_platform_mempool_ops(const char *ops_name) > RTE_MEMPOOL_OPS_NAMESIZE, SOCKET_ID_ANY, 0); > if (mz == NULL) > return -rte_errno; > - strncpy(mz->addr, ops_name, strlen(ops_name)); > + strncpy(mz->addr, ops_name, sizeof(mz->addr) - 1); sizeof(mz->addr) is the size of the pointer, which is probably not what you want. It should be RTE_MEMPOOL_OPS_NAMESIZE. > return 0; > } else if (strcmp(mz->addr, ops_name) == 0) { > return 0; > @@ -62,7 +62,7 @@ rte_mbuf_set_user_mempool_ops(const char *ops_name) > return -rte_errno; > } > > - strncpy(mz->addr, ops_name, strlen(ops_name)); > + strncpy(mz->addr, ops_name, sizeof(mz->addr) - 1); > return 0; Same here. Olivier