Convert os_realloc() for an array to use os_realloc_array()

Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2012-08-13 21:21:23 +03:00
parent b0cda9bd46
commit 067ffa2696
21 changed files with 88 additions and 86 deletions

View file

@ -167,7 +167,7 @@ static int hostapd_config_read_maclist(const char *fname,
if (*pos != '\0') if (*pos != '\0')
vlan_id = atoi(pos); vlan_id = atoi(pos);
newacl = os_realloc(*acl, (*num + 1) * sizeof(**acl)); newacl = os_realloc_array(*acl, *num + 1, sizeof(**acl));
if (newacl == NULL) { if (newacl == NULL) {
wpa_printf(MSG_ERROR, "MAC list reallocation failed"); wpa_printf(MSG_ERROR, "MAC list reallocation failed");
fclose(f); fclose(f);
@ -475,7 +475,7 @@ hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
int ret; int ret;
static int server_index = 1; static int server_index = 1;
nserv = os_realloc(*server, (*num_server + 1) * sizeof(*nserv)); nserv = os_realloc_array(*server, *num_server + 1, sizeof(*nserv));
if (nserv == NULL) if (nserv == NULL)
return -1; return -1;
@ -784,8 +784,8 @@ static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
if (*ifname == '\0') if (*ifname == '\0')
return -1; return -1;
bss = os_realloc(conf->bss, (conf->num_bss + 1) * bss = os_realloc_array(conf->bss, conf->num_bss + 1,
sizeof(struct hostapd_bss_config)); sizeof(struct hostapd_bss_config));
if (bss == NULL) { if (bss == NULL) {
wpa_printf(MSG_ERROR, "Failed to allocate memory for " wpa_printf(MSG_ERROR, "Failed to allocate memory for "
"multi-BSS entry"); "multi-BSS entry");
@ -1258,9 +1258,9 @@ static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
} }
len /= 2; len /= 2;
rc = os_realloc(bss->roaming_consortium, rc = os_realloc_array(bss->roaming_consortium,
sizeof(struct hostapd_roaming_consortium) * bss->roaming_consortium_count + 1,
(bss->roaming_consortium_count + 1)); sizeof(struct hostapd_roaming_consortium));
if (rc == NULL) if (rc == NULL)
return -1; return -1;
@ -1293,9 +1293,8 @@ static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
if (nlen > 252) if (nlen > 252)
goto fail; goto fail;
vn = os_realloc(bss->venue_name, vn = os_realloc_array(bss->venue_name, bss->venue_name_count + 1,
sizeof(struct hostapd_venue_name) * sizeof(struct hostapd_venue_name));
(bss->venue_name_count + 1));
if (vn == NULL) if (vn == NULL)
return -1; return -1;

View file

@ -795,8 +795,9 @@ static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
ap_check_sa_query_timeout(hapd, sta)) ap_check_sa_query_timeout(hapd, sta))
return; return;
nbuf = os_realloc(sta->sa_query_trans_id, nbuf = os_realloc_array(sta->sa_query_trans_id,
(sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN); sta->sa_query_count + 1,
WLAN_SA_QUERY_TR_ID_LEN);
if (nbuf == NULL) if (nbuf == NULL)
return; return;
if (sta->sa_query_count == 0) { if (sta->sa_query_count == 0) {

View file

@ -23,8 +23,8 @@ int hostapd_register_probereq_cb(struct hostapd_data *hapd,
{ {
struct hostapd_probereq_cb *n; struct hostapd_probereq_cb *n;
n = os_realloc(hapd->probereq_cb, (hapd->num_probereq_cb + 1) * n = os_realloc_array(hapd->probereq_cb, hapd->num_probereq_cb + 1,
sizeof(struct hostapd_probereq_cb)); sizeof(struct hostapd_probereq_cb));
if (n == NULL) if (n == NULL)
return -1; return -1;

View file

@ -1328,8 +1328,8 @@ wpa_driver_bsd_add_scan_entry(struct wpa_scan_results *res,
result->ie_len = pos - (u8 *)(result + 1); result->ie_len = pos - (u8 *)(result + 1);
tmp = os_realloc(res->res, tmp = os_realloc_array(res->res, res->num + 1,
(res->num + 1) * sizeof(struct wpa_scan_res *)); sizeof(struct wpa_scan_res *));
if (tmp == NULL) { if (tmp == NULL) {
os_free(result); os_free(result);
return; return;

View file

@ -3988,8 +3988,8 @@ static int bss_info_handler(struct nl_msg *msg, void *arg)
return NL_SKIP; return NL_SKIP;
} }
tmp = os_realloc(res->res, tmp = os_realloc_array(res->res, res->num + 1,
(res->num + 1) * sizeof(struct wpa_scan_res *)); sizeof(struct wpa_scan_res *));
if (tmp == NULL) { if (tmp == NULL) {
os_free(r); os_free(r);
return NL_SKIP; return NL_SKIP;
@ -4784,7 +4784,9 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
return NL_SKIP; return NL_SKIP;
nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) { nla_for_each_nested(nl_band, tb_msg[NL80211_ATTR_WIPHY_BANDS], rem_band) {
mode = os_realloc(phy_info->modes, (*phy_info->num_modes + 1) * sizeof(*mode)); mode = os_realloc_array(phy_info->modes,
*phy_info->num_modes + 1,
sizeof(*mode));
if (!mode) if (!mode)
return NL_SKIP; return NL_SKIP;
phy_info->modes = mode; phy_info->modes = mode;
@ -4951,7 +4953,7 @@ wpa_driver_nl80211_add_11b(struct hostapd_hw_modes *modes, u16 *num_modes)
if (mode11g_idx < 0) if (mode11g_idx < 0)
return modes; /* 2.4 GHz band not supported at all */ return modes; /* 2.4 GHz band not supported at all */
nmodes = os_realloc(modes, (*num_modes + 1) * sizeof(*nmodes)); nmodes = os_realloc_array(modes, *num_modes + 1, sizeof(*nmodes));
if (nmodes == NULL) if (nmodes == NULL)
return modes; /* Could not add 802.11b mode */ return modes; /* Could not add 802.11b mode */
@ -7583,8 +7585,8 @@ static void add_ifidx(struct wpa_driver_nl80211_data *drv, int ifidx)
else else
old = NULL; old = NULL;
drv->if_indices = os_realloc(old, drv->if_indices = os_realloc_array(old, drv->num_if_indices + 1,
sizeof(int) * (drv->num_if_indices + 1)); sizeof(int));
if (!drv->if_indices) { if (!drv->if_indices) {
if (!old) if (!old)
drv->if_indices = drv->default_if_indices; drv->if_indices = drv->default_if_indices;

View file

@ -1414,8 +1414,8 @@ static void wpa_driver_wext_add_scan_entry(struct wpa_scan_results *res,
if (data->ie) if (data->ie)
os_memcpy(pos, data->ie, data->ie_len); os_memcpy(pos, data->ie, data->ie_len);
tmp = os_realloc(res->res, tmp = os_realloc_array(res->res, res->num + 1,
(res->num + 1) * sizeof(struct wpa_scan_res *)); sizeof(struct wpa_scan_res *));
if (tmp == NULL) { if (tmp == NULL) {
os_free(r); os_free(r);
return; return;

View file

@ -946,8 +946,8 @@ int eap_peer_select_phase2_methods(struct eap_peer_config *config,
"method '%s'", start); "method '%s'", start);
} else { } else {
num_methods++; num_methods++;
_methods = os_realloc(methods, _methods = os_realloc_array(methods, num_methods,
num_methods * sizeof(*methods)); sizeof(*methods));
if (_methods == NULL) { if (_methods == NULL) {
os_free(methods); os_free(methods);
os_free(buf); os_free(buf);

View file

@ -52,8 +52,8 @@ struct p2p_group * p2p_group_init(struct p2p_data *p2p,
if (group == NULL) if (group == NULL)
return NULL; return NULL;
groups = os_realloc(p2p->groups, (p2p->num_groups + 1) * groups = os_realloc_array(p2p->groups, p2p->num_groups + 1,
sizeof(struct p2p_group *)); sizeof(struct p2p_group *));
if (groups == NULL) { if (groups == NULL) {
os_free(group); os_free(group);
return NULL; return NULL;

View file

@ -562,8 +562,8 @@ static int radius_msg_add_attr_to_array(struct radius_msg *msg,
size_t *nattr_pos; size_t *nattr_pos;
int nlen = msg->attr_size * 2; int nlen = msg->attr_size * 2;
nattr_pos = os_realloc(msg->attr_pos, nattr_pos = os_realloc_array(msg->attr_pos, nlen,
nlen * sizeof(*msg->attr_pos)); sizeof(*msg->attr_pos));
if (nattr_pos == NULL) if (nattr_pos == NULL)
return -1; return -1;

View file

@ -281,8 +281,8 @@ int radius_client_register(struct radius_client_data *radius,
num = &radius->num_auth_handlers; num = &radius->num_auth_handlers;
} }
newh = os_realloc(*handlers, newh = os_realloc_array(*handlers, *num + 1,
(*num + 1) * sizeof(struct radius_rx_handler)); sizeof(struct radius_rx_handler));
if (newh == NULL) if (newh == NULL)
return -1; return -1;

View file

@ -153,8 +153,8 @@ static int eloop_sock_table_add_sock(struct eloop_sock_table *table,
#ifdef CONFIG_ELOOP_POLL #ifdef CONFIG_ELOOP_POLL
if (new_max_sock >= eloop.max_pollfd_map) { if (new_max_sock >= eloop.max_pollfd_map) {
struct pollfd **nmap; struct pollfd **nmap;
nmap = os_realloc(eloop.pollfds_map, sizeof(struct pollfd *) * nmap = os_realloc_array(eloop.pollfds_map, new_max_sock + 50,
(new_max_sock + 50)); sizeof(struct pollfd *));
if (nmap == NULL) if (nmap == NULL)
return -1; return -1;
@ -165,7 +165,8 @@ static int eloop_sock_table_add_sock(struct eloop_sock_table *table,
if (eloop.count + 1 > eloop.max_poll_fds) { if (eloop.count + 1 > eloop.max_poll_fds) {
struct pollfd *n; struct pollfd *n;
int nmax = eloop.count + 1 + 50; int nmax = eloop.count + 1 + 50;
n = os_realloc(eloop.pollfds, sizeof(struct pollfd) * nmax); n = os_realloc_array(eloop.pollfds, nmax,
sizeof(struct pollfd));
if (n == NULL) if (n == NULL)
return -1; return -1;
@ -175,9 +176,8 @@ static int eloop_sock_table_add_sock(struct eloop_sock_table *table,
#endif /* CONFIG_ELOOP_POLL */ #endif /* CONFIG_ELOOP_POLL */
eloop_trace_sock_remove_ref(table); eloop_trace_sock_remove_ref(table);
tmp = (struct eloop_sock *) tmp = os_realloc_array(table->table, table->count + 1,
os_realloc(table->table, sizeof(struct eloop_sock));
(table->count + 1) * sizeof(struct eloop_sock));
if (tmp == NULL) if (tmp == NULL)
return -1; return -1;
@ -639,10 +639,8 @@ int eloop_register_signal(int sig, eloop_signal_handler handler,
{ {
struct eloop_signal *tmp; struct eloop_signal *tmp;
tmp = (struct eloop_signal *) tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1,
os_realloc(eloop.signals, sizeof(struct eloop_signal));
(eloop.signal_count + 1) *
sizeof(struct eloop_signal));
if (tmp == NULL) if (tmp == NULL)
return -1; return -1;

View file

@ -98,8 +98,8 @@ static int eloop_prepare_handles(void)
if (eloop.num_handles > eloop.reader_count + eloop.event_count + 8) if (eloop.num_handles > eloop.reader_count + eloop.event_count + 8)
return 0; return 0;
n = os_realloc(eloop.handles, n = os_realloc_array(eloop.handles, eloop.num_handles * 2,
eloop.num_handles * 2 * sizeof(eloop.handles[0])); sizeof(eloop.handles[0]));
if (n == NULL) if (n == NULL)
return -1; return -1;
eloop.handles = n; eloop.handles = n;
@ -128,8 +128,8 @@ int eloop_register_read_sock(int sock, eloop_sock_handler handler,
WSACloseEvent(event); WSACloseEvent(event);
return -1; return -1;
} }
tmp = os_realloc(eloop.readers, tmp = os_realloc_array(eloop.readers, eloop.reader_count + 1,
(eloop.reader_count + 1) * sizeof(struct eloop_sock)); sizeof(struct eloop_sock));
if (tmp == NULL) { if (tmp == NULL) {
WSAEventSelect(sock, event, 0); WSAEventSelect(sock, event, 0);
WSACloseEvent(event); WSACloseEvent(event);
@ -191,8 +191,8 @@ int eloop_register_event(void *event, size_t event_size,
if (eloop_prepare_handles()) if (eloop_prepare_handles())
return -1; return -1;
tmp = os_realloc(eloop.events, tmp = os_realloc_array(eloop.events, eloop.event_count + 1,
(eloop.event_count + 1) * sizeof(struct eloop_event)); sizeof(struct eloop_event));
if (tmp == NULL) if (tmp == NULL)
return -1; return -1;
@ -392,9 +392,8 @@ int eloop_register_signal(int sig, eloop_signal_handler handler,
{ {
struct eloop_signal *tmp; struct eloop_signal *tmp;
tmp = os_realloc(eloop.signals, tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1,
(eloop.signal_count + 1) * sizeof(struct eloop_signal));
sizeof(struct eloop_signal));
if (tmp == NULL) if (tmp == NULL)
return -1; return -1;

View file

@ -75,7 +75,7 @@ static void bgscan_learn_add_neighbor(struct bgscan_learn_bss *bss,
if (bssid_in_array(bss->neigh, bss->num_neigh, bssid)) if (bssid_in_array(bss->neigh, bss->num_neigh, bssid))
return; 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) if (n == NULL)
return; return;
@ -219,7 +219,7 @@ static int * bgscan_learn_get_freqs(struct bgscan_learn_data *data,
dl_list_for_each(bss, &data->bss, struct bgscan_learn_bss, list) { dl_list_for_each(bss, &data->bss, struct bgscan_learn_bss, list) {
if (in_array(freqs, bss->freq)) if (in_array(freqs, bss->freq))
continue; continue;
n = os_realloc(freqs, (*count + 2) * sizeof(int)); n = os_realloc_array(freqs, *count + 2, sizeof(int));
if (n == NULL) if (n == NULL)
return freqs; return freqs;
freqs = n; freqs = n;
@ -248,7 +248,7 @@ static int * bgscan_learn_get_probe_freq(struct bgscan_learn_data *data,
wpa_printf(MSG_DEBUG, "bgscan learn: Probe new freq " wpa_printf(MSG_DEBUG, "bgscan learn: Probe new freq "
"%u", data->supp_freqs[idx]); "%u", data->supp_freqs[idx]);
data->probe_idx = 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) if (n == NULL)
return freqs; return freqs;
freqs = n; freqs = n;
@ -360,7 +360,7 @@ static int * bgscan_learn_get_supp_freqs(struct wpa_supplicant *wpa_s)
for (j = 0; j < modes[i].num_channels; j++) { for (j = 0; j < modes[i].num_channels; j++) {
if (modes[i].channels[j].flag & HOSTAPD_CHAN_DISABLED) if (modes[i].channels[j].flag & HOSTAPD_CHAN_DISABLED)
continue; continue;
n = os_realloc(freqs, (count + 2) * sizeof(int)); n = os_realloc_array(freqs, count + 2, sizeof(int));
if (n == NULL) if (n == NULL)
continue; continue;

View file

@ -918,7 +918,7 @@ static int * wpa_config_parse_freqs(const struct parse_data *data,
if (used == len) { if (used == len) {
int *n; int *n;
size_t i; size_t i;
n = os_realloc(freqs, (len * 2 + 1) * sizeof(int)); n = os_realloc_array(freqs, len * 2 + 1, sizeof(int));
if (n == NULL) { if (n == NULL) {
os_free(freqs); os_free(freqs);
return NULL; return NULL;
@ -1047,8 +1047,8 @@ static int wpa_config_parse_eap(const struct parse_data *data,
last = *end == '\0'; last = *end == '\0';
*end = '\0'; *end = '\0';
tmp = methods; tmp = methods;
methods = os_realloc(methods, methods = os_realloc_array(methods, num_methods + 1,
(num_methods + 1) * sizeof(*methods)); sizeof(*methods));
if (methods == NULL) { if (methods == NULL) {
os_free(tmp); os_free(tmp);
os_free(buf); os_free(buf);
@ -1078,7 +1078,7 @@ static int wpa_config_parse_eap(const struct parse_data *data,
os_free(buf); os_free(buf);
tmp = methods; tmp = methods;
methods = os_realloc(methods, (num_methods + 1) * sizeof(*methods)); methods = os_realloc_array(methods, num_methods + 1, sizeof(*methods));
if (methods == NULL) { if (methods == NULL) {
os_free(tmp); os_free(tmp);
return -1; return -1;
@ -1381,7 +1381,7 @@ static int wpa_config_parse_p2p_client_list(const struct parse_data *data,
line, value); line, value);
/* continue anyway */ /* continue anyway */
} else { } else {
n = os_realloc(buf, (count + 1) * ETH_ALEN); n = os_realloc_array(buf, count + 1, ETH_ALEN);
if (n == NULL) { if (n == NULL) {
os_free(buf); os_free(buf);
return -1; return -1;
@ -1669,8 +1669,8 @@ int wpa_config_add_prio_network(struct wpa_config *config,
} }
/* First network for this priority - add a new priority list */ /* First network for this priority - add a new priority list */
nlist = os_realloc(config->pssid, nlist = os_realloc_array(config->pssid, config->num_prio + 1,
(config->num_prio + 1) * sizeof(struct wpa_ssid *)); sizeof(struct wpa_ssid *));
if (nlist == NULL) if (nlist == NULL)
return -1; return -1;
@ -2869,7 +2869,8 @@ static int wpa_config_process_p2p_pref_chan(
pos2++; pos2++;
chan = atoi(pos2); chan = atoi(pos2);
n = os_realloc(pref, (num + 1) * sizeof(struct p2p_channel)); n = os_realloc_array(pref, num + 1,
sizeof(struct p2p_channel));
if (n == NULL) if (n == NULL)
goto fail; goto fail;
pref = n; pref = n;

View file

@ -133,7 +133,7 @@ static int set_bssid_filter(struct wpa_supplicant *wpa_s, char *val)
os_free(filter); os_free(filter);
return -1; return -1;
} }
n = os_realloc(filter, (count + 1) * ETH_ALEN); n = os_realloc_array(filter, count + 1, ETH_ALEN);
if (n == NULL) { if (n == NULL) {
os_free(filter); os_free(filter);
return -1; return -1;
@ -3618,8 +3618,8 @@ static int p2p_ctrl_disallow_freq(struct wpa_supplicant *wpa_s,
*/ */
pos = param; pos = param;
while (pos && pos[0]) { while (pos && pos[0]) {
n = os_realloc(freq, n = os_realloc_array(freq, count + 1,
(count + 1) * sizeof(struct wpa_freq_range)); sizeof(struct wpa_freq_range));
if (n == NULL) { if (n == NULL) {
os_free(freq); os_free(freq);
return -1; return -1;

View file

@ -738,7 +738,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
entry->bytearray_value = NULL; entry->bytearray_value = NULL;
entry->array_type = DBUS_TYPE_BYTE; entry->array_type = DBUS_TYPE_BYTE;
buffer = os_zalloc(BYTE_ARRAY_ITEM_SIZE * BYTE_ARRAY_CHUNK_SIZE); buffer = os_calloc(BYTE_ARRAY_CHUNK_SIZE, BYTE_ARRAY_ITEM_SIZE);
if (!buffer) if (!buffer)
return FALSE; return FALSE;
@ -748,8 +748,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
char byte; char byte;
if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) { if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
nbuffer = os_realloc(buffer, BYTE_ARRAY_ITEM_SIZE * nbuffer = os_realloc_array(
(count + BYTE_ARRAY_CHUNK_SIZE)); buffer, count + BYTE_ARRAY_CHUNK_SIZE,
BYTE_ARRAY_ITEM_SIZE);
if (nbuffer == NULL) { if (nbuffer == NULL) {
os_free(buffer); os_free(buffer);
wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_" wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
@ -795,7 +796,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
entry->strarray_value = NULL; entry->strarray_value = NULL;
entry->array_type = DBUS_TYPE_STRING; entry->array_type = DBUS_TYPE_STRING;
buffer = os_zalloc(STR_ARRAY_ITEM_SIZE * STR_ARRAY_CHUNK_SIZE); buffer = os_calloc(STR_ARRAY_CHUNK_SIZE, STR_ARRAY_ITEM_SIZE);
if (buffer == NULL) if (buffer == NULL)
return FALSE; return FALSE;
@ -806,8 +807,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
char *str; char *str;
if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) { if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
nbuffer = os_realloc(buffer, STR_ARRAY_ITEM_SIZE * nbuffer = os_realloc_array(
(count + STR_ARRAY_CHUNK_SIZE)); buffer, count + STR_ARRAY_CHUNK_SIZE,
STR_ARRAY_ITEM_SIZE);
if (nbuffer == NULL) { if (nbuffer == NULL) {
os_free(buffer); os_free(buffer);
wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_" wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
@ -871,8 +873,8 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_binarray(
buflen += BIN_ARRAY_CHUNK_SIZE; buflen += BIN_ARRAY_CHUNK_SIZE;
newbuf = os_realloc(entry->binarray_value, newbuf = os_realloc_array(entry->binarray_value,
buflen * BIN_ARRAY_ITEM_SIZE); buflen, BIN_ARRAY_ITEM_SIZE);
if (!newbuf) if (!newbuf)
goto cleanup; goto cleanup;
entry->binarray_value = newbuf; entry->binarray_value = newbuf;

View file

@ -1159,8 +1159,9 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
#define FREQS_ALLOC_CHUNK 32 #define FREQS_ALLOC_CHUNK 32
if (freqs_num % FREQS_ALLOC_CHUNK == 0) { if (freqs_num % FREQS_ALLOC_CHUNK == 0) {
nfreqs = os_realloc(freqs, sizeof(int) * nfreqs = os_realloc_array(
(freqs_num + FREQS_ALLOC_CHUNK)); freqs, freqs_num + FREQS_ALLOC_CHUNK,
sizeof(int));
if (nfreqs == NULL) if (nfreqs == NULL)
os_free(freqs); os_free(freqs);
freqs = nfreqs; freqs = nfreqs;
@ -1180,8 +1181,7 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
dbus_message_iter_next(&array_iter); dbus_message_iter_next(&array_iter);
} }
nfreqs = os_realloc(freqs, nfreqs = os_realloc_array(freqs, freqs_num + 1, sizeof(int));
sizeof(int) * (freqs_num + 1));
if (nfreqs == NULL) if (nfreqs == NULL)
os_free(freqs); os_free(freqs);
freqs = nfreqs; freqs = nfreqs;

View file

@ -241,8 +241,8 @@ int main(int argc, char *argv[])
break; break;
case 'N': case 'N':
iface_count++; iface_count++;
iface = os_realloc(ifaces, iface_count * iface = os_realloc_array(ifaces, iface_count,
sizeof(struct wpa_interface)); sizeof(struct wpa_interface));
if (iface == NULL) if (iface == NULL)
goto out; goto out;
ifaces = iface; ifaces = iface;

View file

@ -530,8 +530,8 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
return; /* already in list */ return; /* already in list */
} }
n = os_realloc(s->p2p_client_list, n = os_realloc_array(s->p2p_client_list, s->num_p2p_clients + 1,
(s->num_p2p_clients + 1) * ETH_ALEN); ETH_ALEN);
if (n == NULL) if (n == NULL)
return; return;
os_memcpy(n + s->num_p2p_clients * ETH_ALEN, addr, ETH_ALEN); os_memcpy(n + s->num_p2p_clients * ETH_ALEN, addr, ETH_ALEN);

View file

@ -138,7 +138,7 @@ static void int_array_concat(int **res, const int *a)
reslen = int_array_len(*res); reslen = int_array_len(*res);
alen = int_array_len(a); alen = int_array_len(a);
n = os_realloc(*res, (reslen + alen + 1) * sizeof(int)); n = os_realloc_array(*res, reslen + alen + 1, sizeof(int));
if (n == NULL) { if (n == NULL) {
os_free(*res); os_free(*res);
*res = NULL; *res = NULL;

View file

@ -951,9 +951,9 @@ static void sme_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
sme_check_sa_query_timeout(wpa_s)) sme_check_sa_query_timeout(wpa_s))
return; return;
nbuf = os_realloc(wpa_s->sme.sa_query_trans_id, nbuf = os_realloc_array(wpa_s->sme.sa_query_trans_id,
(wpa_s->sme.sa_query_count + 1) * wpa_s->sme.sa_query_count + 1,
WLAN_SA_QUERY_TR_ID_LEN); WLAN_SA_QUERY_TR_ID_LEN);
if (nbuf == NULL) if (nbuf == NULL)
return; return;
if (wpa_s->sme.sa_query_count == 0) { if (wpa_s->sme.sa_query_count == 0) {