aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/hs20_supplicant.c
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2015-12-19 16:53:27 (GMT)
committerJouni Malinen <j@w1.fi>2015-12-19 16:53:27 (GMT)
commit61f25f80b46e0d0247f168385b94a904e3c6fc04 (patch)
tree605b7d472780fe043b3b5c1c2958e6b7b11efdfe /wpa_supplicant/hs20_supplicant.c
parentca9968a0129927c916081817a2e4c187e79a47fc (diff)
downloadhostap-61f25f80b46e0d0247f168385b94a904e3c6fc04.zip
hostap-61f25f80b46e0d0247f168385b94a904e3c6fc04.tar.gz
hostap-61f25f80b46e0d0247f168385b94a904e3c6fc04.tar.bz2
HS 2.0: Remove duplicate icon entries
Only one of the icon entries with a matching BSSID and file name can be fetched from wpa_supplicant and as such, there is no need to maintain the old data if it was not explicitly deleted before running a new fetch for the same BSSID and icon. Remove older duplicated entries whenever completing a pending icon fetch to optimize memory use. Signed-off-by: Jouni Malinen <j@w1.fi>
Diffstat (limited to 'wpa_supplicant/hs20_supplicant.c')
-rw-r--r--wpa_supplicant/hs20_supplicant.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/wpa_supplicant/hs20_supplicant.c b/wpa_supplicant/hs20_supplicant.c
index 3eeb5a2..57b9943 100644
--- a/wpa_supplicant/hs20_supplicant.c
+++ b/wpa_supplicant/hs20_supplicant.c
@@ -357,6 +357,25 @@ static void hs20_set_osu_access_permission(const char *osu_dir,
}
}
+
+static void hs20_remove_duplicate_icons(struct wpa_supplicant *wpa_s,
+ struct icon_entry *new_icon)
+{
+ struct icon_entry *icon, *tmp;
+
+ dl_list_for_each_safe(icon, tmp, &wpa_s->icon_head, struct icon_entry,
+ list) {
+ if (icon == new_icon)
+ continue;
+ if (os_memcmp(icon->bssid, new_icon->bssid, ETH_ALEN) == 0 &&
+ os_strcmp(icon->file_name, new_icon->file_name) == 0) {
+ dl_list_del(&icon->list);
+ hs20_free_icon_entry(icon);
+ }
+ }
+}
+
+
static int hs20_process_icon_binary_file(struct wpa_supplicant *wpa_s,
const u8 *sa, const u8 *pos,
size_t slen, u8 dialog_token)
@@ -375,6 +394,7 @@ static int hs20_process_icon_binary_file(struct wpa_supplicant *wpa_s,
return -1;
os_memcpy(icon->image, pos, slen);
icon->image_len = slen;
+ hs20_remove_duplicate_icons(wpa_s, icon);
wpa_msg(wpa_s, MSG_INFO,
"RX-HS20-ICON " MACSTR " %s %u",
MAC2STR(sa), icon->file_name,