]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
PASN: Fix testing code parsing for PASN_DRIVER
authorJouni Malinen <j@w1.fi>
Sat, 18 Oct 2025 08:18:42 +0000 (11:18 +0300)
committerJouni Malinen <j@w1.fi>
Sat, 18 Oct 2025 19:32:25 +0000 (22:32 +0300)
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 <j@w1.fi>
wpa_supplicant/ctrl_iface.c

index 519667e3a4cd00e8a55650926028e990e65f0403..688d2034b22dd9c50e187bfdedf0b614be074b1e 100644 (file)
@@ -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) {