path: root/src/ap/wpa_auth_glue.c
diff options
authorMichael Braun <michael-dev@fami-braun.de>2012-08-04 17:55:47 (GMT)
committerJouni Malinen <j@w1.fi>2012-08-04 17:55:47 (GMT)
commit59dff51dc84e83da0778e954a64f030865d864bd (patch)
tree95e34e4935c79e96d87f9ce9d230bc1ca22647a9 /src/ap/wpa_auth_glue.c
parentaddde1399ec4f5ddf448ad738274e1fb6c9d9b03 (diff)
Fix endless loop in PSK fetching with PSK-from-RADIUS
Commit 05ab9712b9977192b713f01f07c3b14ca4d1ba78 added support for fetching WPA PSK from an external RADIUS server and changed hostapd_wpa_auth_get_psk() to always return the RADIUS supplied PSK (if set) and ignore the prev_psk parameter for iteration. Fix this by appending the RADIUS supplied PSK to the list iterated by hostapd_get_psk and thus returning NULL when prev_psk == sta->psk (RADIUS). Signed-hostap: M. Braun <michael-dev@fami-braun.de>
Diffstat (limited to 'src/ap/wpa_auth_glue.c')
1 files changed, 9 insertions, 3 deletions
diff --git a/src/ap/wpa_auth_glue.c b/src/ap/wpa_auth_glue.c
index fa4182c..edcdf60 100644
--- a/src/ap/wpa_auth_glue.c
+++ b/src/ap/wpa_auth_glue.c
@@ -184,9 +184,15 @@ static const u8 * hostapd_wpa_auth_get_psk(void *ctx, const u8 *addr,
struct hostapd_data *hapd = ctx;
struct sta_info *sta = ap_get_sta(hapd, addr);
- if (sta && sta->psk)
- return sta->psk;
- return hostapd_get_psk(hapd->conf, addr, prev_psk);
+ const u8 *psk = hostapd_get_psk(hapd->conf, addr, prev_psk);
+ /*
+ * This is about to iterate over all psks, prev_psk gives the last
+ * returned psk which should not be returned again.
+ * logic list (all hostapd_get_psk; sta->psk)
+ */
+ if (sta && sta->psk && !psk && sta->psk != prev_psk)
+ psk = sta->psk;
+ return psk;