From fbacedaef80f4d93fcf08345fe14b4d0aab6bbdb Mon Sep 17 00:00:00 2001 From: Jamie McCrae Date: Thu, 22 Jun 2023 08:52:23 +0100 Subject: [PATCH] mgmt: mcumgr: grp: shell_mgmt: Fix issue with unset variable Fixes an issue where a variable was used without being correctly set by other parts of the code. Signed-off-by: Jamie McCrae --- subsys/mgmt/mcumgr/grp/shell_mgmt/src/shell_mgmt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/subsys/mgmt/mcumgr/grp/shell_mgmt/src/shell_mgmt.c b/subsys/mgmt/mcumgr/grp/shell_mgmt/src/shell_mgmt.c index 067b02d87be..f6cb3f014ba 100644 --- a/subsys/mgmt/mcumgr/grp/shell_mgmt/src/shell_mgmt.c +++ b/subsys/mgmt/mcumgr/grp/shell_mgmt/src/shell_mgmt.c @@ -83,9 +83,6 @@ shell_mgmt_exec(struct smp_streamer *ctxt) ok = zcbor_tstr_decode(zsd, &value); if (ok) { - /* TODO: This is original error when failed to collect command line - * to buffer, but should be rather MGMT_ERR_ENOMEM. - */ if ((len + value.len) >= (ARRAY_SIZE(line) - 1)) { ok = smp_add_cmd_ret(zse, MGMT_GROUP_ID_SHELL, SHELL_MGMT_RET_RC_COMMAND_TOO_LONG); @@ -95,7 +92,7 @@ shell_mgmt_exec(struct smp_streamer *ctxt) memcpy(&line[len], value.value, value.len); len += value.len + 1; line[len - 1] = ' '; - } else { + } else if (len > 0) { line[len - 1] = 0; /* Implicit break by while condition */ }