From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id C22FEA0096 for ; Thu, 14 Mar 2019 02:01:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D4EFE37B0; Thu, 14 Mar 2019 02:01:51 +0100 (CET) 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) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2019 18:01:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,476,1544515200"; d="scan'208";a="131470429" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga008.fm.intel.com with ESMTP; 13 Mar 2019 18:01:49 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 13 Mar 2019 18:01:48 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 13 Mar 2019 18:01:48 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.134]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.80]) with mapi id 14.03.0415.000; Thu, 14 Mar 2019 09:01:46 +0800 From: "Zhang, Qi Z" To: Stephen Hemminger CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] ethdev: check for invalid device name Thread-Index: AQHU2DaADbRsMlE2skqXgTAnwfRHKaYJhVhQ///JmACAAQL50A== 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> In-Reply-To: <20190313103232.35804089@shemminger-XPS-13-9360> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjkxYWI3NzQtNzg5My00YTFlLWE5YjUtYjEyN2Y0MzJkNzNhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiRlwvSWlqVlFlWkxsVklqdHNzNjdqZWdxVzJ0U2RERWNcLzBDUHdCYzVXZ09LYkxsYmVFbFVBRzJPcnFFbDFXZ2lxIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] ethdev: check for invalid device name 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190314010145.an7Z2qO71PVF9HyK06dN_GSQogFJhddHoPhyHsKMgv8@z> > -----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