From 9f0205b4d6ca11a176ee840b80d43f5d0fbbfdad Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 18 Oct 2025 11:18:42 +0300 Subject: [PATCH] PASN: Fix testing code parsing for PASN_DRIVER Incorrect indentation level hid the issue with the peer pointer not being verified correctly. Fix the indentation level to make it clear that peer might be NULL here and reject the cases that would have resulted in dereferencting a NULL pointer. This code is included only with CONFIG_TESTING_OPTIONS. Fixes: ba7d967da46d ("PASN: Testing support for PASN with user-specified parameters") Signed-off-by: Jouni Malinen --- wpa_supplicant/ctrl_iface.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index 519667e3a..688d2034b 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -11638,14 +11638,23 @@ static int wpas_ctrl_iface_pasn_driver(struct wpa_supplicant *wpa_s, char *cmd) if (hwaddr_aton(token + 6, bssid)) goto out; - if (event.pasn_auth.num_peers == WPAS_MAX_PASN_PEERS) + if (event.pasn_auth.num_peers == WPAS_MAX_PASN_PEERS) + goto out; + peer = &event.pasn_auth.peer[event.pasn_auth.num_peers]; + os_memcpy(peer->own_addr, wpa_s->own_addr, ETH_ALEN); + os_memcpy(peer->peer_addr, bssid, ETH_ALEN); + event.pasn_auth.num_peers++; + continue; + } + + if (!peer) { + wpa_printf(MSG_INFO, + "CTRL: PASN: No peer (bssid) specified before parameter '%s'", + token); goto out; - peer = &event.pasn_auth.peer[event.pasn_auth.num_peers]; - os_memcpy(peer->own_addr, wpa_s->own_addr, ETH_ALEN); - os_memcpy(peer->peer_addr, bssid, ETH_ALEN); - event.pasn_auth.num_peers++; + } - } else if (os_strcmp(token, "akmp=PASN") == 0) { + if (os_strcmp(token, "akmp=PASN") == 0) { peer->akmp = WPA_KEY_MGMT_PASN; #ifdef CONFIG_IEEE80211R } else if (os_strcmp(token, "akmp=FT-PSK") == 0) { -- 2.47.3