hostapd: update to version 2016-09-05
[openwrt/openwrt.git] / package / network / services / hostapd / patches / 390-wpa_ie_cap_workaround.patch
1 --- a/src/common/wpa_common.c
2 +++ b/src/common/wpa_common.c
3 @@ -1246,6 +1246,31 @@ u32 wpa_akm_to_suite(int akm)
4 }
5
6
7 +static void wpa_fixup_wpa_ie_rsn(u8 *assoc_ie, const u8 *wpa_msg_ie,
8 + size_t rsn_ie_len)
9 +{
10 + int pos, count;
11 +
12 + pos = sizeof(struct rsn_ie_hdr) + RSN_SELECTOR_LEN;
13 + if (rsn_ie_len < pos + 2)
14 + return;
15 +
16 + count = WPA_GET_LE16(wpa_msg_ie + pos);
17 + pos += 2 + count * RSN_SELECTOR_LEN;
18 + if (rsn_ie_len < pos + 2)
19 + return;
20 +
21 + count = WPA_GET_LE16(wpa_msg_ie + pos);
22 + pos += 2 + count * RSN_SELECTOR_LEN;
23 + if (rsn_ie_len < pos + 2)
24 + return;
25 +
26 + if (!assoc_ie[pos] && !assoc_ie[pos + 1] &&
27 + (wpa_msg_ie[pos] || wpa_msg_ie[pos + 1]))
28 + memcpy(&assoc_ie[pos], &wpa_msg_ie[pos], 2);
29 +}
30 +
31 +
32 int wpa_compare_rsn_ie(int ft_initial_assoc,
33 const u8 *ie1, size_t ie1len,
34 const u8 *ie2, size_t ie2len)
35 @@ -1253,8 +1278,19 @@ int wpa_compare_rsn_ie(int ft_initial_as
36 if (ie1 == NULL || ie2 == NULL)
37 return -1;
38
39 - if (ie1len == ie2len && os_memcmp(ie1, ie2, ie1len) == 0)
40 - return 0; /* identical IEs */
41 + if (ie1len == ie2len) {
42 + u8 *ie_tmp;
43 +
44 + if (os_memcmp(ie1, ie2, ie1len) == 0)
45 + return 0; /* identical IEs */
46 +
47 + ie_tmp = alloca(ie1len);
48 + memcpy(ie_tmp, ie1, ie1len);
49 + wpa_fixup_wpa_ie_rsn(ie_tmp, ie2, ie1len);
50 +
51 + if (os_memcmp(ie_tmp, ie2, ie1len) == 0)
52 + return 0; /* only mismatch in RSN capabilties */
53 + }
54
55 #ifdef CONFIG_IEEE80211R
56 if (ft_initial_assoc) {