From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 40C641B60A for ; Mon, 23 Oct 2017 14:57:49 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2017 05:57:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,422,1503385200"; d="scan'208";a="1234109203" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.32]) by fmsmga002.fm.intel.com with SMTP; 23 Oct 2017 05:57:46 -0700 Received: by (sSMTP sendmail emulation); Mon, 23 Oct 2017 13:57:46 +0100 Date: Mon, 23 Oct 2017 13:57:45 +0100 From: Bruce Richardson To: Kirill Rybalchenko Cc: dev@dpdk.org, andrey.chilikin@intel.com, beilei.xing@intel.com, jingjing.wu@intel.com Message-ID: <20171023125745.GA26976@bricha3-MOBL3.ger.corp.intel.com> References: <1508757889-40845-1-git-send-email-kirill.rybalchenko@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1508757889-40845-1-git-send-email-kirill.rybalchenko@intel.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.9.1 (2017-09-22) Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix value of num parameter for strncpy function 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: Mon, 23 Oct 2017 12:57:50 -0000 On Mon, Oct 23, 2017 at 12:24:49PM +0100, Kirill Rybalchenko wrote: > num parameter for strncpy() function should be smaller than > actual destination buffer size to allow null termination. > > Fixes: 40d1324423a4 ("net/i40e: get ddp profile protocol info") > > Signed-off-by: Kirill Rybalchenko > --- > drivers/net/i40e/rte_pmd_i40e.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/i40e/rte_pmd_i40e.c b/drivers/net/i40e/rte_pmd_i40e.c > index 4881ea0..489f66b 100644 > --- a/drivers/net/i40e/rte_pmd_i40e.c > +++ b/drivers/net/i40e/rte_pmd_i40e.c > @@ -1928,7 +1928,7 @@ int rte_pmd_i40e_get_ddp_info(uint8_t *pkg_buff, uint32_t pkg_size, > for (i = j = 0; i < nb_rec; j++) { > pinfo[j].proto_id = tlv->data[0]; > strncpy(pinfo[j].name, (const char *)&tlv->data[1], > - I40E_DDP_NAME_SIZE); > + I40E_DDP_NAME_SIZE - 1); > i += tlv->len; > tlv = &tlv[tlv->len]; > } > -- This is not a proper fix, as it still won't null-terminate the result. Replace strncpy with snprintf is probably the best solution. /Bruce