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 E60B4998C for ; Thu, 25 May 2017 11:52:01 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 May 2017 02:52:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,391,1491289200"; d="scan'208";a="91624618" Received: from yliu-dev.sh.intel.com ([10.239.67.162]) by orsmga002.jf.intel.com with ESMTP; 25 May 2017 02:52:00 -0700 From: Yuanhan Liu To: Wenzhuo Lu Cc: Yuanhan Liu , Olivier Matz , dpdk stable Date: Thu, 25 May 2017 17:49:21 +0800 Message-Id: <1495705809-21416-109-git-send-email-yuanhan.liu@linux.intel.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1495705809-21416-1-git-send-email-yuanhan.liu@linux.intel.com> References: <1495705809-21416-1-git-send-email-yuanhan.liu@linux.intel.com> Subject: [dpdk-stable] patch 'cmdline: fix parsing' has been queued to stable release 17.02.1 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: Thu, 25 May 2017 09:52:02 -0000 Hi, FYI, your patch has been queued to stable release 17.02.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/28/17. So please shout if anyone has objections. Thanks. --yliu --- >>From 34d71a72819e5f16c7acb30a5c29c10a6fa77f73 Mon Sep 17 00:00:00 2001 From: Wenzhuo Lu Date: Tue, 25 Apr 2017 11:11:25 +0800 Subject: [PATCH] cmdline: fix parsing [ upstream commit 9b3fbb051d2e98161b68c8f5c60331170be7b853 ] 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. 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 result has no chance to be changed. Fixes: af75078fece3 ("first public release") Signed-off-by: Wenzhuo Lu Acked-by: Olivier Matz --- lib/librte_cmdline/cmdline_parse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 @@ cmdline_parse(struct cmdline *cl, const char * buf) 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 *) = NULL; void *data = NULL; @@ -321,14 +321,16 @@ cmdline_parse(struct cmdline *cl, const char * buf) debug_printf("INST %d\n", inst_num); /* fully parsed */ - tok = match_inst(inst, buf, 0, result.buf, sizeof(result.buf), - &dyn_tokens); + tok = match_inst(inst, buf, 0, tmp_result.buf, + sizeof(tmp_result.buf), &dyn_tokens); 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++; -- 1.9.0