DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Zhao1, Wei" <wei.zhao1@intel.com>
To: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>,
	"dev@dpdk.org" <dev@dpdk.org>
Cc: "stable@dpdk.org" <stable@dpdk.org>, "Peng, Yuan" <yuan.peng@intel.com>
Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow	commandline
Date: Thu, 6 Dec 2018 02:34:21 +0000	[thread overview]
Message-ID: <A2573D2ACFCADC41BB3BE09C6DE313CA07E7A853@PGSMSX101.gar.corp.intel.com> (raw)
In-Reply-To: <2601191342CEEE43887BDE71AB977258010CEBF553@IRSMSX106.ger.corp.intel.com>



> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Tuesday, December 4, 2018 5:22 PM
> To: Zhao1, Wei <wei.zhao1@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org; Peng, Yuan <yuan.peng@intel.com>; Zhao1, Wei
> <wei.zhao1@intel.com>
> Subject: RE: [dpdk-dev] [PATCH] app/testpmd: add boundary check in flow
> commandline
> 
> 
> 
> > -----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 <yuan.peng@intel.com>; Zhao1, Wei
> > <wei.zhao1@intel.com>
> > 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 <wei.zhao1@intel.com>
> > ---
> >  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 token
> *token,
> >  	}
> >  	buf = (uint8_t *)ctx->object + arg->offset;
> >  	size = 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

Ok, I will commit v2.

> 
> >  objmask:
> >  	switch (size) {
> >  	case sizeof(uint8_t):
> > --
> > 2.7.5

  reply	other threads:[~2018-12-06  2:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-04  5:51 Wei Zhao
2018-12-04  7:46 ` Zhao1, Wei
2018-12-04  9:22 ` Ananyev, Konstantin
2018-12-06  2:34   ` Zhao1, Wei [this message]
2018-12-06  2:38 ` [dpdk-dev] [PATCH v2] " Wei Zhao
2018-12-21 15:05   ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A2573D2ACFCADC41BB3BE09C6DE313CA07E7A853@PGSMSX101.gar.corp.intel.com \
    --to=wei.zhao1@intel.com \
    --cc=dev@dpdk.org \
    --cc=konstantin.ananyev@intel.com \
    --cc=stable@dpdk.org \
    --cc=yuan.peng@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).