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 3732F5F28 for ; Wed, 12 Dec 2018 11:30:46 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2018 02:30:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,344,1539673200"; d="scan'208";a="106821707" Received: from bricha3-mobl.ger.corp.intel.com ([10.237.221.32]) by fmsmga007.fm.intel.com with SMTP; 12 Dec 2018 02:30:43 -0800 Received: by (sSMTP sendmail emulation); Wed, 12 Dec 2018 03:30:43 -0700 Date: Wed, 12 Dec 2018 03:30:42 -0700 From: Bruce Richardson To: "Burakov, Anatoly" Cc: Jakub Grajciar , "dev@dpdk.org" 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 Content-Disposition: inline In-Reply-To: <54ae65dd-a51f-baa9-1eb2-ea0b18996c25@intel.com> Organization: Intel Research and Development Ireland Ltd. User-Agent: Mutt/1.10.1 (2018-07-13) Subject: Re: [dpdk-dev] [RFC v2] /net: memory interface (memif) 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: Wed, 12 Dec 2018 10:30:47 -0000 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