From 7f8a292cc60f0f31b3cdefcf82997550201832ab Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Sat, 20 Apr 2024 21:04:29 +0530 Subject: [PATCH] net: wifi: Check for mandatory args MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even though we are passing mandatory args from the shell registration, due to use of getopt the check can be bypassed without the hyphenated options. So, enforce and fail if mandatory parameters aren't passed through getopt. (cherry picked from commit b29dff09fad980d8ac2084c38fd4be16b39867b4) Original-Signed-off-by: Chaitanya Tata GitOrigin-RevId: b29dff09fad980d8ac2084c38fd4be16b39867b4 Change-Id: I4cbc49f118f946879775733f3c14d53778fdab91 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5482304 Tested-by: Dawid Niedźwiecki Tested-by: ChromeOS Prod (Robot) Reviewed-by: Dawid Niedźwiecki Commit-Queue: Dawid Niedźwiecki --- subsys/net/l2/wifi/wifi_shell.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/subsys/net/l2/wifi/wifi_shell.c b/subsys/net/l2/wifi/wifi_shell.c index 489b3b7e977..642f5d1fbf9 100644 --- a/subsys/net/l2/wifi/wifi_shell.c +++ b/subsys/net/l2/wifi/wifi_shell.c @@ -574,6 +574,16 @@ static int __wifi_args_to_params(const struct shell *sh, size_t argc, char *argv if (params->psk && !secure_connection) { PR_WARNING("Passphrase provided without security configuration\n"); } + + if (!params->ssid) { + PR_ERROR("SSID not provided\n"); + return -EINVAL; + } + + if (iface_mode == WIFI_MODE_AP && params->channel == WIFI_CHANNEL_ANY) { + PR_ERROR("Channel not provided\n"); + return -EINVAL; + } return 0; }