cfg80211: fix cmp_ies
When comparing two items by IE, the sort order wasn't stable, which could lead to issues in the rbtree. Make it stable by making a missing IE sort before a present IE. Also sort by length first if it differs and then by contents. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
133a3ff2c9
commit
3b6ef6334f
@ -259,17 +259,20 @@ static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2)
|
|||||||
{
|
{
|
||||||
const u8 *ie1 = cfg80211_find_ie(num, ies1, len1);
|
const u8 *ie1 = cfg80211_find_ie(num, ies1, len1);
|
||||||
const u8 *ie2 = cfg80211_find_ie(num, ies2, len2);
|
const u8 *ie2 = cfg80211_find_ie(num, ies2, len2);
|
||||||
int r;
|
|
||||||
|
|
||||||
|
/* equal if both missing */
|
||||||
if (!ie1 && !ie2)
|
if (!ie1 && !ie2)
|
||||||
return 0;
|
return 0;
|
||||||
if (!ie1 || !ie2)
|
/* sort missing IE before (left of) present IE */
|
||||||
|
if (!ie1)
|
||||||
return -1;
|
return -1;
|
||||||
|
if (!ie2)
|
||||||
|
return 1;
|
||||||
|
|
||||||
r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1]));
|
/* sort by length first, then by contents */
|
||||||
if (r == 0 && ie1[1] != ie2[1])
|
if (ie1[1] != ie2[1])
|
||||||
return ie2[1] - ie1[1];
|
return ie2[1] - ie1[1];
|
||||||
return r;
|
return memcmp(ie1 + 2, ie2 + 2, ie1[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool is_bss(struct cfg80211_bss *a,
|
static bool is_bss(struct cfg80211_bss *a,
|
||||||
|
Loading…
Reference in New Issue
Block a user