From patchwork Wed Oct 7 09:38:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Loftus, Ciara" X-Patchwork-Id: 79852 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F3FFDA04BA; Wed, 7 Oct 2020 12:05:19 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 990DE1E34; Wed, 7 Oct 2020 12:05:18 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id D1AB8A3 for ; Wed, 7 Oct 2020 12:05:16 +0200 (CEST) IronPort-SDR: VUhIyTp9cIXHbeiMs0NTEhSorBj1D3MZyLxUXiNzbNaWlhI3cSLrfCNsXVLTq6ujNOCm/ZqQPX 9jp0Wdz+tauA== X-IronPort-AV: E=McAfee;i="6000,8403,9766"; a="229024039" X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="229024039" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 03:05:15 -0700 IronPort-SDR: kGlIIRsNYETPhEZm9k0mojwXAhgvKQTUIbtQkBsf6PlNlKSJSmjZ4VT6HvNQ17nSqTlzcFyTz9 YXO4TaxGxLEQ== X-IronPort-AV: E=Sophos;i="5.77,346,1596524400"; d="scan'208";a="527877285" Received: from silpixa00399839.ir.intel.com (HELO localhost.localdomain) ([10.237.222.142]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2020 03:05:14 -0700 From: Ciara Loftus To: dev@dpdk.org Cc: Ciara Loftus Date: Wed, 7 Oct 2020 09:38:54 +0000 Message-Id: <20201007093854.30573-1-ciara.loftus@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201007093535.29828-1-ciara.loftus@intel.com> References: <20201007093535.29828-1-ciara.loftus@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v4] net/af_xdp: use rte_strscpy 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" strncpy may leave the destination buffer not NULL terminated so use rte_strscpy instead. Coverity issue: 362975 Fixes: 339b88c6a91f ("net/af_xdp: support multi-queue") Signed-off-by: Ciara Loftus --- v4: * actually use rte_strscpy instead of strlcpy v3: * use rte_strscpy instead of strlcpy v2: * use strlcpy instead of snprintf 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..f394c57a74 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); + rte_strscpy(ifr.ifr_name, if_name, IFNAMSIZ); ret = ioctl(fd, SIOCETHTOOL, &ifr); if (ret) { if (errno == EOPNOTSUPP) {