You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/26 12:40:45 UTC
(mynewt-core) 03/07: sys/shell: Reject shell exec request without arguments
This is an automated email from the ASF dual-hosted git repository.
sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit c544f4562a3087fc9b596eb70afd3e9f1724c72a
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Sun Oct 25 19:14:59 2026 +0100
sys/shell: Reject shell exec request without arguments
If "argv" was missing from the request or was not an array, argc was
not set by the decoder and its uninitialized value was used as index
for NULL terminating argv, before being passed to shell_exec() along
with uninitialized argv.
The decoder now sets argc to 0 in that case, but shell_exec() expects
at least one argument and dereferences argv[0] when an app command
handler is registered. Return an error if no arguments were provided.
Assisted-by: Claude:claude-opus-5-5
---
sys/shell/src/shell_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/shell/src/shell_bridge.c b/sys/shell/src/shell_bridge.c
index 5255317df..97319c756 100644
--- a/sys/shell/src/shell_bridge.c
+++ b/sys/shell/src/shell_bridge.c
@@ -73,7 +73,7 @@ shell_bridge_exec(struct mgmt_ctxt *cb)
};
err = cbor_read_object(&cb->it, attrs);
- if (err != 0) {
+ if (err != 0 || argc < 1) {
return MGMT_ERR_EINVAL;
}