Initialize binary result memory before parsing to avoid garbage in parsing result.
Signed-off-by: Xueming Li <xuemi...@mellanox.com> --- 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; } } -- 2.13.3