From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Zhang, Qi Z" Subject: Re: [PATCH] ethdev: check for invalid device name Date: Thu, 14 Mar 2019 01:01:45 +0000 Message-ID: <039ED4275CED7440929022BC67E706115334C632@SHSMSX103.ccr.corp.intel.com> References: <20190311181544.15646-1-stephen@networkplumber.org> <039ED4275CED7440929022BC67E706115334BE52@SHSMSX103.ccr.corp.intel.com> <20190313103232.35804089@shemminger-XPS-13-9360> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: "dev@dpdk.org" To: Stephen Hemminger Return-path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 1AEA02BF5 for ; Thu, 14 Mar 2019 02:01:49 +0100 (CET) In-Reply-To: <20190313103232.35804089@shemminger-XPS-13-9360> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Thursday, March 14, 2019 1:33 AM > To: Zhang, Qi Z > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] ethdev: check for invalid device name >=20 > On Wed, 13 Mar 2019 12:52:50 +0000 > "Zhang, Qi Z" wrote: >=20 > > HI > > > > > -----Original Message----- > > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen > > > Hemminger > > > Sent: Tuesday, March 12, 2019 2:16 AM > > > To: dev@dpdk.org > > > Cc: Stephen Hemminger > > > Subject: [dpdk-dev] [PATCH] ethdev: check for invalid device name > > > > > > Do not allow creating a ethernet device with a name over the allowed > > > maximum (or zero length). This is safer than silently truncating whic= h is what > happens now. > > > > > > Signed-off-by: Stephen Hemminger > > > Acked-by: Andrew Rybchenko > > > --- > > > v1 - previously sent as RFC > > > > > > lib/librte_ethdev/rte_ethdev.c | 10 ++++++++++ > > > 1 file changed, 10 insertions(+) > > > > > > diff --git a/lib/librte_ethdev/rte_ethdev.c > > > b/lib/librte_ethdev/rte_ethdev.c index 85c1794968dd..0b81980ff71c > > > 100644 > > > --- a/lib/librte_ethdev/rte_ethdev.c > > > +++ b/lib/librte_ethdev/rte_ethdev.c > > > @@ -439,6 +439,16 @@ rte_eth_dev_allocate(const char *name) > > > uint16_t port_id; > > > struct rte_eth_dev *eth_dev =3D NULL; > > > > > > + if (*name) { > > > > Is above check same as "strlen(name) =3D=3D 0"? >=20 > Yes, but checking for first null byte is slightly quicker. Alternative wo= uld be to call > strnlen() once. But you are checking the not null byte here right? should it be if (!(*name= ))? =09