diff --git a/src/cli/cli.cpp b/src/cli/cli.cpp index 47bf4d497..233617572 100644 --- a/src/cli/cli.cpp +++ b/src/cli/cli.cpp @@ -1889,6 +1889,9 @@ void Interpreter::ProcessLine(char *aBuf, uint16_t aBufLength, Server &aServer) for (cmd = aBuf + 1; (cmd < aBuf + aBufLength) && (cmd != NULL); ++cmd) { + VerifyOrExit(argc < kMaxArgs, + sServer->OutputFormat("Error: too many args (max %d)\r\n", kMaxArgs)); + if (*cmd == ' ' || *cmd == '\r' || *cmd == '\n') { *cmd = '\0';