From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 7E7A169D4; Thu, 6 Dec 2018 03:34:28 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Dec 2018 18:34:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,320,1539673200"; d="scan'208";a="125488181" Received: from pgsmsx103.gar.corp.intel.com ([10.221.44.82]) by fmsmga004.fm.intel.com with ESMTP; 05 Dec 2018 18:34:26 -0800 Received: from pgsmsx101.gar.corp.intel.com ([169.254.1.244]) by PGSMSX103.gar.corp.intel.com ([169.254.2.155]) with mapi id 14.03.0415.000; Thu, 6 Dec 2018 10:34:22 +0800 From: "Zhao1, Wei" To: "Ananyev, Konstantin" , "dev@dpdk.org" CC: "stable@dpdk.org" , "Peng, Yuan" Thread-Topic: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Thread-Index: AQHUi7LfArzbSKllB0em9twEu3DznKVxAONw Date: Thu, 6 Dec 2018 02:34:21 +0000 Message-ID: References: <1543902690-71857-1-git-send-email-wei.zhao1@intel.com> <2601191342CEEE43887BDE71AB977258010CEBF553@IRSMSX106.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB977258010CEBF553@IRSMSX106.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [172.30.20.205] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline 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: Thu, 06 Dec 2018 02:34:29 -0000 > -----Original Message----- > From: Ananyev, Konstantin > Sent: Tuesday, December 4, 2018 5:22 PM > To: Zhao1, Wei ; dev@dpdk.org > Cc: stable@dpdk.org; Peng, Yuan ; Zhao1, Wei > > Subject: RE: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow > commandline >=20 >=20 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wei Zhao > > Sent: Tuesday, December 4, 2018 5:52 AM > > To: dev@dpdk.org > > Cc: stable@dpdk.org; Peng, Yuan ; Zhao1, Wei > > > > Subject: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow > > commandline > > > > There is need to add boundary for input number from commandline, If it > > beyond the defination, code will return error. > > > > Signed-off-by: Wei Zhao > > --- > > app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++ > > 1 file changed, 19 insertions(+) > > > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > > index 23ea7cc..515f95c 100644 > > --- a/app/test-pmd/cmdline_flow.c > > +++ b/app/test-pmd/cmdline_flow.c > > @@ -4325,6 +4325,25 @@ parse_int(struct context *ctx, const struct toke= n > *token, > > } > > buf =3D (uint8_t *)ctx->object + arg->offset; > > size =3D arg->size; > > + switch (size) { > > + case sizeof(uint8_t): > > + if (u > 0xff) > > + return -1; > > + case sizeof(uint16_t): > > + if (u > 0xffff) > > + return -1; > > + case sizeof(uint8_t [3]): > > + if (u > 0xffffff) > > + return -1; > > + case sizeof(uint32_t): > > + if (u > 0xffffffff) > > + return -1; > > + case sizeof(uint64_t): > > + if (u > 0xffffffffffffffff) > > + return -1; > > + default: > > + break; > > + } >=20 > Why just not something like: > if (u > RTE_LEN2MASK(size * CHAR_BIT)) > return -1; > ? > Konstantin Ok, I will commit v2. >=20 > > objmask: > > switch (size) { > > case sizeof(uint8_t): > > -- > > 2.7.5