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 3DEAEA04BA; Wed, 7 Oct 2020 11:40:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 59B352BC7; Wed, 7 Oct 2020 11:40:38 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 255D71DBF for ; Wed, 7 Oct 2020 11:40:36 +0200 (CEST) IronPort-SDR: lbjBrfUGLgDZ6bINwc3LOYxnuULgh5xz3d6nsdW7VJwvYqUkMPgXPSNJiNIWaCbDDNLYu0AHeQ 9VN+MfA2URxw== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="164109297" X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="164109297" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 02:40:34 -0700 IronPort-SDR: z+xLKeDchWO3Q1V5eCyiu3RUxzZcXO/bMn/R6uZkZWIsoo0a+PVp3gPSrX1BqcjkBOr70zSp0p 6pzIOZsAUf6w== X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="461250134" Received: from fyigit-mobl1.ger.corp.intel.com (HELO [10.213.193.102]) ([10.213.193.102]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 02:40:34 -0700 To: Ciara Loftus , dev@dpdk.org References: <20201007090137.5121-1-ciara.loftus@intel.com> From: Ferruh Yigit Message-ID: Date: Wed, 7 Oct 2020 10:40:32 +0100 MIME-Version: 1.0 In-Reply-To: <20201007090137.5121-1-ciara.loftus@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH] net/af_xdp: use snprintf instead of strncpy 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" On 10/7/2020 10:01 AM, Ciara Loftus wrote: > strncpy may leave the destination buffer not NULL terminated so use > snprintf instead. What do you think using 'strlcpy'? > > Coverity issue: 362975 > Fixes: 339b88c6a91f ("net/af_xdp: support multi-queue") > Signed-off-by: Ciara Loftus > --- > drivers/net/af_xdp/rte_eth_af_xdp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c > index eaf2c9c873..52495cb8fb 100644 > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c > @@ -1362,7 +1362,7 @@ xdp_get_channels_info(const char *if_name, int *max_queues, > > channels.cmd = ETHTOOL_GCHANNELS; > ifr.ifr_data = (void *)&channels; > - strncpy(ifr.ifr_name, if_name, IFNAMSIZ); > + snprintf(ifr.ifr_name, IFNAMSIZ, "%s", if_name); > ret = ioctl(fd, SIOCETHTOOL, &ifr); > if (ret) { > if (errno == EOPNOTSUPP) { >