From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bruce Richardson Subject: Re: [RFC v2] /net: memory interface (memif) Date: Wed, 12 Dec 2018 03:30:42 -0700 Message-ID: <20181212103042.GA3336@bricha3-MOBL.ger.corp.intel.com> References: <20181210091457.6031-1-jgrajcia@cisco.com> <20181210100639.30244-1-jgrajcia@cisco.com> <7ebcd985-0d04-c0e1-5411-8e02c8bc72b2@intel.com> <59AF69C657FD0841A61C55336867B5B0726FADC1@IRSMSX103.ger.corp.intel.com> <54ae65dd-a51f-baa9-1eb2-ea0b18996c25@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Jakub Grajciar , "dev@dpdk.org" To: "Burakov, Anatoly" Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 3732F5F28 for ; Wed, 12 Dec 2018 11:30:46 +0100 (CET) Content-Disposition: inline In-Reply-To: <54ae65dd-a51f-baa9-1eb2-ea0b18996c25@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 Wed, Dec 12, 2018 at 10:19:02AM +0000, Burakov, Anatoly wrote: > On 10-Dec-18 10:50 AM, Richardson, Bruce wrote: > > > > > > > -----Original Message----- > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Burakov, Anatoly > > > Sent: Monday, December 10, 2018 10:43 AM > > > To: Jakub Grajciar ; dev@dpdk.org > > > Subject: Re: [dpdk-dev] [RFC v2] /net: memory interface (memif) > > > > > > On 10-Dec-18 10:06 AM, Jakub Grajciar wrote: > > > > Signed-off-by: Jakub Grajciar > > > > --- > > > > > > As a general comment, some description/cover letter would have been nice. > > > > > > > + > > > > + memif_msg_disconnect_t *d = &e->msg.disconnect; > > > > + > > > > + e->msg.type = MEMIF_MSG_TYPE_DISCONNECT; > > > > + d->code = err_code; > > > > + > > > > + if (reason != NULL) { > > > > + strncpy((char *)d->string, reason, strlen(reason)); > > > > + if (cc->pmd != NULL) { > > > > + strncpy(cc->pmd->local_disc_string, reason, > > > > + strlen(reason)); > > > > + } > > > > > > I haven't looked at the entire thing, this is just something that caught > > > my eye during quick skimming through code. > > > > > > On the face of it, this looks dangerous - you're setting the destination > > > buffer size from source buffer size. What if `d->string` is shorter than > > > `reason`? > > > > > > > And strncpy is dangerous - use strlcpy instead. > > Isn't strscpy the string copy function du jour now? :) > Well, it's certainly the new one! It's only available as a DPDK-specific function though - "rte_strscpy". Therefore, I think strlcpy is generally preferred, but either will do. /Bruce