From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A7F4C1B209; Tue, 4 Dec 2018 10:22:24 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Dec 2018 01:22:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,313,1539673200"; d="scan'208";a="115886536" Received: from irsmsx107.ger.corp.intel.com ([163.33.3.99]) by FMSMGA003.fm.intel.com with ESMTP; 04 Dec 2018 01:22:23 -0800 Received: from irsmsx112.ger.corp.intel.com (10.108.20.5) by IRSMSX107.ger.corp.intel.com (163.33.3.99) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 4 Dec 2018 09:22:22 +0000 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.8]) by irsmsx112.ger.corp.intel.com ([169.254.1.93]) with mapi id 14.03.0415.000; Tue, 4 Dec 2018 09:22:22 +0000 From: "Ananyev, Konstantin" To: "Zhao1, Wei" , "dev@dpdk.org" CC: "stable@dpdk.org" , "Peng, Yuan" , "Zhao1, Wei" Thread-Topic: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow commandline Thread-Index: AQHUi5kA5UDS88RdqUuLjYrtW+G+LaVuTQhw Date: Tue, 4 Dec 2018 09:22:21 +0000 Message-ID: <2601191342CEEE43887BDE71AB977258010CEBF553@IRSMSX106.ger.corp.intel.com> References: <1543902690-71857-1-git-send-email-wei.zhao1@intel.com> In-Reply-To: <1543902690-71857-1-git-send-email-wei.zhao1@intel.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiN2Q2NjhkMGItNzVjNS00NjNhLTg5MDUtNjViOWFhYjU3OTlhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiM0JzUWozSXBnMG5SdXh4bjNCZWRqdG0rZUx0Mmk5V2hrWlNldkFrdEtlRmtRaGJEQzNcLzZOVlFpd2pTWitaRlAifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [163.33.239.181] 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: Tue, 04 Dec 2018 09:22:25 -0000 > -----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 comma= ndline >=20 > There is need to add boundary for input number from commandline, > If it beyond the defination, code will return error. >=20 > Signed-off-by: Wei Zhao > --- > app/test-pmd/cmdline_flow.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) >=20 > 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 token = *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; > + } Why just not something like: if (u > RTE_LEN2MASK(size * CHAR_BIT)) return -1; ? Konstantin > objmask: > switch (size) { > case sizeof(uint8_t): > -- > 2.7.5