Merge branch 'fix/fix_openthread_cli' into 'master'

fix(openthread): check if the command is valid before calling the input function

See merge request espressif/esp-idf!42002
This commit is contained in:
Shu Chen
2025-09-23 06:23:19 +00:00

View File

@@ -65,6 +65,7 @@ esp_err_t esp_openthread_cli_input(const char *line)
static int ot_cli_console_callback(int argc, char **argv) static int ot_cli_console_callback(int argc, char **argv)
{ {
ESP_RETURN_ON_FALSE(argv[1] != NULL && strlen(argv[1]) > 0, ESP_FAIL, OT_PLAT_LOG_TAG, "Invalid OpenThread command");
char cli_cmd[OT_CLI_MAX_LINE_LENGTH] = {0}; char cli_cmd[OT_CLI_MAX_LINE_LENGTH] = {0};
strncpy(cli_cmd, argv[1], sizeof(cli_cmd) - strlen(cli_cmd) - 1); strncpy(cli_cmd, argv[1], sizeof(cli_cmd) - strlen(cli_cmd) - 1);
for (int i = 2; i < argc; i++) { for (int i = 2; i < argc; i++) {