aboutsummaryrefslogtreecommitdiffstats
path: root/net/wireless/scan.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2012-11-28 16:42:34 -0500
committerJohannes Berg <johannes.berg@intel.com>2012-11-30 07:41:26 -0500
commitf94f8b168cf2e46da180bbba2afd626d7af0579d (patch)
tree44c5efcf76dce5438bd078744e6a695b3a40e478 /net/wireless/scan.c
parent915de2ff4a79f1f98362035060777b6c8ce889bb (diff)
cfg80211: fix cmp_hidden_bss
The cmp_bss() comparator function uses memcmp() to compare the SSID. This means that cmp_hidden_bss() needs to similarly return a number bigger than zero (use 1) instead of -1 when ie1 is bigger than ie2, which is the case if an ie2 byte is non-zero. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/scan.c')
-rw-r--r--net/wireless/scan.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 92339105aa3b..834e0d153fbe 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -450,10 +450,16 @@ static int cmp_hidden_bss(struct cfg80211_bss *a, struct cfg80211_bss *b)
450 b->information_elements, 450 b->information_elements,
451 b->len_information_elements); 451 b->len_information_elements);
452 452
453 /* Key comparator must use same algorithm in any rb-tree 453 /*
454 * Key comparator must use same algorithm in any rb-tree
454 * search function (order is important), otherwise ordering 455 * search function (order is important), otherwise ordering
455 * of items in the tree is broken and search gives incorrect 456 * of items in the tree is broken and search gives incorrect
456 * results. This code uses same order as cmp_ies() does. */ 457 * results. This code uses same order as cmp_ies() does.
458 *
459 * Note that due to the differring behaviour with hidden SSIDs
460 * this function only works when "b" is the tree element and
461 * "a" is the key we're looking for.
462 */
457 463
458 /* sort missing IE before (left of) present IE */ 464 /* sort missing IE before (left of) present IE */
459 if (!ie1) 465 if (!ie1)
@@ -469,10 +475,14 @@ static int cmp_hidden_bss(struct cfg80211_bss *a, struct cfg80211_bss *b)
469 if (ie1[1] != ie2[1]) 475 if (ie1[1] != ie2[1])
470 return ie2[1] - ie1[1]; 476 return ie2[1] - ie1[1];
471 477
472 /* zeroed SSID ie is another indication of a hidden bss */ 478 /*
479 * zeroed SSID ie is another indication of a hidden bss;
480 * if it isn't zeroed just return the regular sort value
481 * to find the next candidate
482 */
473 for (i = 0; i < ie2[1]; i++) 483 for (i = 0; i < ie2[1]; i++)
474 if (ie2[i + 2]) 484 if (ie2[i + 2])
475 return -1; 485 return memcmp(ie1 + 2, ie2 + 2, ie1[1]);
476 486
477 return 0; 487 return 0;
478} 488}