Skip to content

Commit c65d781

Browse files
committed
net: lib: wifi_credentials: Fix sonar warnings
Fix code warnings. Signed-off-by: Triveni Danda <[email protected]>
1 parent 76fb4b9 commit c65d781

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

subsys/net/lib/wifi_credentials/wifi_credentials_shell.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ static int cmd_add_network(const struct shell *sh, size_t argc, char *argv[])
192192
while ((opt = getopt_long(argc, argv, "s:p:k:w:b:c:m:t:a:K:h", long_options, &opt_index)) !=
193193
-1) {
194194
state = getopt_state_get();
195+
if (!state->optarg) {
196+
shell_warn(sh, "Provided argument is NULL\n");
197+
return -EINVAL;
198+
}
199+
195200
switch (opt) {
196201
case 's':
197202
creds.header.ssid_len = strlen(state->optarg);
@@ -201,6 +206,7 @@ static int cmd_add_network(const struct shell *sh, size_t argc, char *argv[])
201206
return -EINVAL;
202207
}
203208
memcpy(creds.header.ssid, state->optarg, creds.header.ssid_len);
209+
creds.header.ssid[creds.header.ssid_len] = '\0';
204210
break;
205211
case 'k':
206212
creds.header.type = atoi(state->optarg);

0 commit comments

Comments
 (0)