From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 7BC3C6A71 for ; Tue, 8 May 2018 10:58:40 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 May 2018 01:58:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,377,1520924400"; d="scan'208";a="54094492" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.55]) by orsmga001.jf.intel.com with SMTP; 08 May 2018 01:58:37 -0700 Received: by (sSMTP sendmail emulation); Tue, 08 May 2018 09:58:36 +0100 Date: Tue, 8 May 2018 09:58:36 +0100 From: Bruce Richardson To: Andy Green Cc: dev@dpdk.org Message-ID: <20180508085835.GB20636@bricha3-MOBL.ger.corp.intel.com> References: <152575364588.56689.3300796065057551728.stgit@localhost.localdomain> <152575379320.56689.8382051384798098704.stgit@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152575379320.56689.8382051384798098704.stgit@localhost.localdomain> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 05/18] drivers: net: nfp: nfpcore: fix strncpy misuse 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, 08 May 2018 08:58:40 -0000 On Tue, May 08, 2018 at 12:29:53PM +0800, Andy Green wrote: > > --- > drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c > index 4e6c66624..9f6704a7f 100644 > --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c > +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c > @@ -846,7 +846,8 @@ nfp6000_init(struct nfp_cpp *cpp, const char *devname) > > > memset(desc->busdev, 0, BUSDEV_SZ); > - strncpy(desc->busdev, devname, strlen(devname)); > + strncpy(desc->busdev, devname, sizeof(desc->busdev) - 1); > + desc->busdev[sizeof(desc->busdev) - 1] = '\0'; > > ret = nfp_acquire_process_lock(desc); > if (ret) As with previous patch, a better fix is to use strlcpy. This would apply to just about all uses of strncpy in the code. /Bruce