From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [PATCH] app/procinfo: fix strncpy count issue Date: Tue, 20 Feb 2018 13:29:14 +0000 Message-ID: <20180220132914.GA10780@bricha3-MOBL3.ger.corp.intel.com> References: <1519131456-9928-1-git-send-email-radu.nicolau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, john.mcnamara@intel.com, maryam.tahhan@intel.com, reshma.pattan@intel.com, stable@dpdk.org To: Radu Nicolau Return-path: Content-Disposition: inline In-Reply-To: <1519131456-9928-1-git-send-email-radu.nicolau@intel.com> 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 Tue, Feb 20, 2018 at 12:57:36PM +0000, Radu Nicolau wrote: > Change strncpy count parameter to MAX_LONG_OPT_SZ-1 to avoid > overwriting the last NULL character and for consistency. > > Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id") > Coverity issue: 30688 > > Cc: stable@dpdk.org > > Signed-off-by: Radu Nicolau > --- strncpy is a very nasty function that is easy to get wrong. Rather than fixing it's off by one errors, I think a better fix is to use snprintf as is done in most other places. /Bruce