[PATCH 31/44] psk list sharing

michael-dev at fami-braun.de michael-dev at fami-braun.de
Wed Feb 24 03:53:37 PST 2016


From: Michael Braun <michael-dev at fami-braun.de>

The hashing the passphrases, this results in the hashed version hitting
back the cache and being cached as well.

Signed-off-by: Michael Braun <michael-dev at fami-braun.de>
---
 src/ap/ap_config.h       |  1 +
 src/ap/ieee802_11_auth.c | 29 ++++++++++++-----------------
 2 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 9b09c16..2143fc3 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -137,6 +137,7 @@ struct hostapd_sta_wpa_psk_short {
 	int ispassphrase;
 	u8 psk[PMK_LEN];
 	char passphrase[PASSPHRASE_LEN];
+	int ref; /* (number of references hold) - 1 */
 };
 
 struct hostapd_wpa_psk {
diff --git a/src/ap/ieee802_11_auth.c b/src/ap/ieee802_11_auth.c
index e007a73..c6a5b67 100644
--- a/src/ap/ieee802_11_auth.c
+++ b/src/ap/ieee802_11_auth.c
@@ -78,23 +78,13 @@ static void hostapd_acl_cache_free(struct hostapd_cached_radius_acl *acl_cache)
 static void copy_psk_list(struct hostapd_sta_wpa_psk_short **psk,
 			  struct hostapd_sta_wpa_psk_short *src)
 {
-	struct hostapd_sta_wpa_psk_short **copy_to;
-	struct hostapd_sta_wpa_psk_short *copy_from;
-
-	/* Copy PSK linked list */
-	copy_to = psk;
-	copy_from = src;
-	while (copy_from && copy_to) {
-		*copy_to = os_zalloc(sizeof(struct hostapd_sta_wpa_psk_short));
-		if (*copy_to == NULL)
-			break;
-		os_memcpy(*copy_to, copy_from,
-			  sizeof(struct hostapd_sta_wpa_psk_short));
-		copy_from = copy_from->next;
-		copy_to = &((*copy_to)->next);
-	}
-	if (copy_to)
-		*copy_to = NULL;
+	if (!psk)
+		return;
+
+	if (src)
+		src->ref++;
+
+	*psk = src;
 }
 
 
@@ -674,6 +664,11 @@ void hostapd_acl_deinit(struct hostapd_data *hapd)
 
 void hostapd_free_psk_list(struct hostapd_sta_wpa_psk_short *psk)
 {
+	if (psk && psk->ref) {
+		psk->ref--;
+		return;
+	}
+
 	while (psk) {
 		struct hostapd_sta_wpa_psk_short *prev = psk;
 		psk = psk->next;
-- 
1.9.1




More information about the Hostap mailing list