1 --- a/wpa_supplicant/wpa_supplicant.c
2 +++ b/wpa_supplicant/wpa_supplicant.c
3 @@ -1248,7 +1248,7 @@ static int wpa_supplicant_get_scan_resul
5 #define SCAN_AP_LIMIT 128
6 struct wpa_scan_result *results;
9 struct wpa_scan_results *res;
11 results = os_malloc(SCAN_AP_LIMIT * sizeof(struct wpa_scan_result));
12 @@ -1345,6 +1345,21 @@ static int wpa_supplicant_get_scan_resul
13 res->res[res->num++] = r;
16 + /* sort scan results by quality */
17 + for(i = 0; i < num - 1; i++) {
18 + for(j = i + 1; j < num; j++) {
19 + struct wpa_scan_result tmp;
21 + if (results[i].qual > results[j].qual)
24 + os_memcpy(&tmp, &results[i], sizeof(tmp));
25 + os_memcpy(&results[i], &results[j], sizeof(tmp));
26 + os_memcpy(&results[j], &tmp, sizeof(tmp));
32 wpa_s->scan_res = res;