* WPA Supplicant - background scan and roaming module: learn
* Copyright (c) 2009-2010, Jouni Malinen <j@w1.fi>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Alternatively, this software may be distributed under the terms of BSD
- * license.
- *
- * See README and COPYING for more details.
+ * This software may be distributed under the terms of the BSD license.
+ * See README for more details.
*/
#include "includes.h"
if (bssid_in_array(bss->neigh, bss->num_neigh, bssid))
return;
- n = os_realloc(bss->neigh, (bss->num_neigh + 1) * ETH_ALEN);
+ n = os_realloc_array(bss->neigh, bss->num_neigh + 1, ETH_ALEN);
if (n == NULL)
return;
dl_list_for_each(bss, &data->bss, struct bgscan_learn_bss, list) {
if (in_array(freqs, bss->freq))
continue;
- n = os_realloc(freqs, (*count + 2) * sizeof(int));
+ n = os_realloc_array(freqs, *count + 2, sizeof(int));
if (n == NULL)
return freqs;
freqs = n;
idx = data->probe_idx + 1;
while (idx != data->probe_idx) {
- if (data->supp_freqs[idx] == 0)
+ if (data->supp_freqs[idx] == 0) {
+ if (data->probe_idx == 0)
+ break;
idx = 0;
+ }
if (!in_array(freqs, data->supp_freqs[idx])) {
wpa_printf(MSG_DEBUG, "bgscan learn: Probe new freq "
"%u", data->supp_freqs[idx]);
data->probe_idx = idx;
- n = os_realloc(freqs, (count + 2) * sizeof(int));
+ n = os_realloc_array(freqs, count + 2, sizeof(int));
if (n == NULL)
return freqs;
freqs = n;
static int * bgscan_learn_get_supp_freqs(struct wpa_supplicant *wpa_s)
{
struct hostapd_hw_modes *modes;
- u16 num_modes, flags;
int i, j, *freqs = NULL, *n;
size_t count = 0;
- modes = wpa_drv_get_hw_feature_data(wpa_s, &num_modes, &flags);
- if (!modes)
+ modes = wpa_s->hw.modes;
+ if (modes == NULL)
return NULL;
- for (i = 0; i < num_modes; i++) {
+ for (i = 0; i < wpa_s->hw.num_modes; i++) {
for (j = 0; j < modes[i].num_channels; j++) {
if (modes[i].channels[j].flag & HOSTAPD_CHAN_DISABLED)
continue;
- n = os_realloc(freqs, (count + 2) * sizeof(int));
- if (!n)
+ n = os_realloc_array(freqs, count + 2, sizeof(int));
+ if (n == NULL)
continue;
freqs = n;
count++;
freqs[count] = 0;
}
- os_free(modes[i].channels);
- os_free(modes[i].rates);
}
- os_free(modes);
return freqs;
}