From 3871154b720569b12e037af88ac2ea9e8a0a1ace Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Wed, 5 Oct 2016 23:50:49 +0000 Subject: [PATCH] lib: Invalid commands are errors, fix msg formatting Signed-off-by: Quentin Young --- lib/command.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/command.c b/lib/command.c index d2720e1161..6368ebffe1 100644 --- a/lib/command.c +++ b/lib/command.c @@ -284,14 +284,17 @@ cmd_free_strvec (vector v) char * cmd_concat_strvec (vector v) { - size_t strsize = 1; + size_t strsize = 0; for (unsigned int i = 0; i < vector_active (v); i++) if (vector_slot (v, i)) - strsize += strlen ((char *) vector_slot (v, i)); + strsize += strlen ((char *) vector_slot (v, i)) + 1; char *concatenated = calloc (sizeof (char), strsize); for (unsigned int i = 0; i < vector_active (v); i++) + { strlcat (concatenated, (char *) vector_slot (v, i), strsize); + strlcat (concatenated, " ", strsize); + } return concatenated; } @@ -724,7 +727,7 @@ cmd_execute_command_real (vector vline, default: {} // C... char *inputline = cmd_concat_strvec (vline); - zlog_debug ("invalid command %s for node %d\n", inputline, vty->node); + zlog_err ("invalid command \"%s\" for node %d\n", inputline, vty->node); free (inputline); return CMD_ERR_NO_MATCH; } -- 2.39.5