Skip to content

Commit 3caaabb

Browse files
jukkarkrish2718
authored andcommitted
[nrf fromtree] wifi: shell: btm_query: Fix invalid pointer cast
The 11v_btm_query shell command was calling parse_number() using a pointer to uint8_t. This will cause memory overwrite and possible crash. Convert to use long temporary value to avoid this. Fix also the output prints in case of an error. Signed-off-by: Jukka Rissanen <[email protected]> (cherry picked from commit c6aa9e3)
1 parent 352cc8c commit 3caaabb

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,16 +1674,19 @@ static int cmd_wifi_btm_query(const struct shell *sh, size_t argc, char *argv[])
16741674
{
16751675
struct net_if *iface = net_if_get_first_wifi();
16761676
uint8_t query_reason = 0;
1677+
long tmp = 0;
16771678

16781679
context.sh = sh;
16791680

1680-
if (!parse_number(sh, (long *)&query_reason, argv[1], NULL,
1681+
if (!parse_number(sh, &tmp, argv[1], NULL,
16811682
WIFI_BTM_QUERY_REASON_UNSPECIFIED, WIFI_BTM_QUERY_REASON_LEAVING_ESS)) {
16821683
return -EINVAL;
16831684
}
16841685

1686+
query_reason = tmp;
1687+
16851688
if (net_mgmt(NET_REQUEST_WIFI_BTM_QUERY, iface, &query_reason, sizeof(query_reason))) {
1686-
PR_WARNING("Setting BTM query Reason failed..Reason :%d\n", query_reason);
1689+
PR_WARNING("Setting BTM query Reason failed. Reason : %d\n", query_reason);
16871690
return -ENOEXEC;
16881691
}
16891692

0 commit comments

Comments
 (0)