From patchwork Fri Dec 8 07:02:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xueming Li X-Patchwork-Id: 32016 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1A0357CFD; Fri, 8 Dec 2017 08:47:40 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 13CA87CBD for ; Fri, 8 Dec 2017 08:47:38 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from xuemingl@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2017 09:02:51 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (dev-r630-06.mtbc.labs.mlnx [10.12.205.180]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id vB872oCU023103; Fri, 8 Dec 2017 09:02:51 +0200 Received: from dev-r630-06.mtbc.labs.mlnx (localhost [127.0.0.1]) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7) with ESMTP id vB872nWh024179; Fri, 8 Dec 2017 15:02:49 +0800 Received: (from xuemingl@localhost) by dev-r630-06.mtbc.labs.mlnx (8.14.7/8.14.7/Submit) id vB872mwU024166; Fri, 8 Dec 2017 15:02:48 +0800 From: Xueming Li To: Olivier MATZ Cc: Xueming Li , dev@dpdk.org Date: Fri, 8 Dec 2017 15:02:44 +0800 Message-Id: <20171208070244.24094-1-xuemingl@mellanox.com> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20171115155402.9967-1-xuemingl@mellanox.com> References: <20171115155402.9967-1-xuemingl@mellanox.com> Subject: [dpdk-dev] [PATCH v1] lib/cmdline: init parse result memory 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Initialize binary result memory before parsing to avoid garbage in parsing result. Signed-off-by: Xueming Li --- lib/librte_cmdline/cmdline_parse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_cmdline/cmdline_parse.c b/lib/librte_cmdline/cmdline_parse.c index 3e12ee54f..4072103f2 100644 --- a/lib/librte_cmdline/cmdline_parse.c +++ b/lib/librte_cmdline/cmdline_parse.c @@ -168,6 +168,9 @@ match_inst(cmdline_parse_inst_t *inst, const char *buf, int n = 0; struct cmdline_token_hdr token_hdr; + if (resbuf != NULL) + memset(resbuf, 0, resbuf_size); + /* check if we match all tokens of inst */ while (!nb_match_token || i < nb_match_token) { token_p = get_token(inst, i); @@ -338,8 +341,8 @@ cmdline_parse(struct cmdline *cl, const char * buf) err = CMDLINE_PARSE_AMBIGUOUS; f=NULL; debug_printf("Ambiguous cmd\n"); - break; } + break; } }