DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xueming(Steven) Li" <xuemingl@mellanox.com>
To: "Xueming(Steven) Li" <xuemingl@mellanox.com>,
	Olivier MATZ <olivier.matz@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	"stable@dpdk.org" <stable@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] cmdline: fix dynamic tokens parsing
Date: Sat, 20 Jan 2018 02:30:05 +0000	[thread overview]
Message-ID: <VI1PR05MB1678B70DE68C6508B5E50321ACEE0@VI1PR05MB1678.eurprd05.prod.outlook.com> (raw)
In-Reply-To: <20180120022554.131490-1-xuemingl@mellanox.com>

Hi Olivier,

Almost forgot this one, my original proposal for CLI issue.
Split out according to your suggestion.

Thanks,
Xueming

> -----Original Message-----
> From: Xueming Li [mailto:xuemingl@mellanox.com]
> Sent: Saturday, January 20, 2018 10:26 AM
> To: Olivier MATZ <olivier.matz@6wind.com>
> Cc: Xueming(Steven) Li <xuemingl@mellanox.com>; dev@dpdk.org; Adrien
> Mazarguil <adrien.mazarguil@6wind.com>; stable@dpdk.org
> Subject: [PATCH] cmdline: fix dynamic tokens parsing
> 
> When using dynamic tokens, the result buffer contains pointers to some
> location inside the result buffer. When the content of the temporary
> buffer is copied in the final one, these pointers still point to the
> temporary buffer.
> 
> This works until the temporary buffer is kept intact, but the next commit
> introduces a memset() that breaks this assumption.
> 
> This commit keeps the successfully parsed buffers, and ensures that the
> pointers point to the valid location, by using temp buffer for following
> parsing.
> 
> Fixes: 9b3fbb051d2e ("cmdline: fix parsing")
> Cc: stable@dpdk.org
> Signed-off-by: Xueming Li <xuemingl@mellanox.com>
> ---
>  lib/librte_cmdline/cmdline_parse.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_cmdline/cmdline_parse.c
> b/lib/librte_cmdline/cmdline_parse.c
> index 3e12ee54f..c74b146fc 100644
> --- a/lib/librte_cmdline/cmdline_parse.c
> +++ b/lib/librte_cmdline/cmdline_parse.c
> @@ -263,6 +263,7 @@ cmdline_parse(struct cmdline *cl, const char * buf)
> #ifdef RTE_LIBRTE_CMDLINE_DEBUG
>  	char debug_buf[BUFSIZ];
>  #endif
> +	char *result_buf = result.buf;
> 
>  	if (!cl || !buf)
>  		return CMDLINE_PARSE_BAD_ARGS;
> @@ -312,16 +313,14 @@ cmdline_parse(struct cmdline *cl, const char * buf)
>  		debug_printf("INST %d\n", inst_num);
> 
>  		/* fully parsed */
> -		tok = match_inst(inst, buf, 0, tmp_result.buf,
> -				 sizeof(tmp_result.buf));
> +		tok = match_inst(inst, buf, 0, result_buf,
> +				 CMDLINE_PARSE_RESULT_BUFSIZE);
> 
>  		if (tok > 0) /* we matched at least one token */
>  			err = CMDLINE_PARSE_BAD_ARGS;
> 
>  		else if (!tok) {
>  			debug_printf("INST fully parsed\n");
> -			memcpy(&result, &tmp_result,
> -			       sizeof(result));
>  			/* skip spaces */
>  			while (isblank2(*curbuf)) {
>  				curbuf++;
> @@ -332,6 +331,7 @@ cmdline_parse(struct cmdline *cl, const char * buf)
>  				if (!f) {
>  					memcpy(&f, &inst->f, sizeof(f));
>  					memcpy(&data, &inst->data, sizeof(data));
> +					result_buf = tmp_result.buf;
>  				}
>  				else {
>  					/* more than 1 inst matches */
> --
> 2.13.3


  reply	other threads:[~2018-01-20  2:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-20  2:25 Xueming Li
2018-01-20  2:30 ` Xueming(Steven) Li [this message]
2018-01-20  3:27   ` Xueming(Steven) Li

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=VI1PR05MB1678B70DE68C6508B5E50321ACEE0@VI1PR05MB1678.eurprd05.prod.outlook.com \
    --to=xuemingl@mellanox.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    --cc=stable@dpdk.org \
    /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).