From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 4E21D2935; Fri, 28 Apr 2017 10:38:27 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Apr 2017 01:38:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,387,1488873600"; d="scan'208";a="79974973" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga002.jf.intel.com with ESMTP; 28 Apr 2017 01:38:25 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 28 Apr 2017 01:38:25 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 28 Apr 2017 01:38:25 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.246]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Fri, 28 Apr 2017 16:38:23 +0800 From: "Lu, Wenzhuo" To: "olivier.matz@6wind.com" CC: "stable@dpdk.org" , "Glynn, Michael J" , "Liu, Yu Y" , "dev@dpdk.org" Thread-Topic: [PATCH] lib/librte_cmdline: fix CLI parsing issue Thread-Index: AQHSvXGUJr9pc00AXEa0NxDE8Inpq6HaejFg Date: Fri, 28 Apr 2017 08:38:21 +0000 Message-ID: <6A0DE07E22DDAD4C9103DF62FEBC09093B59DB03@shsmsx102.ccr.corp.intel.com> References: <1493089885-94889-1-git-send-email-wenzhuo.lu@intel.com> In-Reply-To: <1493089885-94889-1-git-send-email-wenzhuo.lu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-stable] [PATCH] lib/librte_cmdline: fix CLI parsing issue X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Apr 2017 08:38:27 -0000 Hi Oilvier, As we discussed before, I send this patch. Would you like to take a look at= it? Better fix it before release 17.05, thanks. > -----Original Message----- > From: Lu, Wenzhuo > Sent: Tuesday, April 25, 2017 11:11 AM > To: dev@dpdk.org > Cc: olivier.matz@6wind.com; Lu, Wenzhuo; stable@dpdk.org > Subject: [PATCH] lib/librte_cmdline: fix CLI parsing issue >=20 > When parsing a CLI, all the CLI instances are checked one by one. Even if= an > instance already matches the CLI, the parsing will not stop for ambiguous > check. > The problem is that the following check may change the parsing result of = the > previous one even if the following instance doesn't match. >=20 > Use a temporary validate for the parsing result when trying to match an > instance and only store the result when it matches, so the previous resul= t > has no chance to be changed. >=20 > Fixes: af75078fece3 ("first public release") > CC: stable@dpdk.org >=20 > Signed-off-by: Wenzhuo Lu > --- > lib/librte_cmdline/cmdline_parse.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_cmdline/cmdline_parse.c > b/lib/librte_cmdline/cmdline_parse.c > index 763c286..b814880 100644 > --- a/lib/librte_cmdline/cmdline_parse.c > +++ b/lib/librte_cmdline/cmdline_parse.c > @@ -258,7 +258,7 @@ > union { > char buf[CMDLINE_PARSE_RESULT_BUFSIZE]; > long double align; /* strong alignment constraint for buf */ > - } result; > + } result, tmp_result; > cmdline_parse_token_hdr_t > *dyn_tokens[CMDLINE_PARSE_DYNAMIC_TOKENS]; > void (*f)(void *, struct cmdline *, void *) =3D NULL; > void *data =3D NULL; > @@ -321,14 +321,16 @@ > debug_printf("INST %d\n", inst_num); >=20 > /* fully parsed */ > - tok =3D match_inst(inst, buf, 0, result.buf, sizeof(result.buf), > - &dyn_tokens); > + tok =3D match_inst(inst, buf, 0, tmp_result.buf, > + sizeof(tmp_result.buf), &dyn_tokens); >=20 > if (tok > 0) /* we matched at least one token */ > err =3D CMDLINE_PARSE_BAD_ARGS; >=20 > else if (!tok) { > debug_printf("INST fully parsed\n"); > + memcpy(&result, &tmp_result, > + sizeof(result)); > /* skip spaces */ > while (isblank2(*curbuf)) { > curbuf++; > -- > 1.9.3