Convert os_realloc() for an array to use os_realloc_array()
Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
b0cda9bd46
commit
067ffa2696
21 changed files with 88 additions and 86 deletions
|
@ -167,7 +167,7 @@ static int hostapd_config_read_maclist(const char *fname,
|
|||
if (*pos != '\0')
|
||||
vlan_id = atoi(pos);
|
||||
|
||||
newacl = os_realloc(*acl, (*num + 1) * sizeof(**acl));
|
||||
newacl = os_realloc_array(*acl, *num + 1, sizeof(**acl));
|
||||
if (newacl == NULL) {
|
||||
wpa_printf(MSG_ERROR, "MAC list reallocation failed");
|
||||
fclose(f);
|
||||
|
@ -475,7 +475,7 @@ hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
|
|||
int ret;
|
||||
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)
|
||||
return -1;
|
||||
|
||||
|
@ -784,7 +784,7 @@ static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
|
|||
if (*ifname == '\0')
|
||||
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));
|
||||
if (bss == NULL) {
|
||||
wpa_printf(MSG_ERROR, "Failed to allocate memory for "
|
||||
|
@ -1258,9 +1258,9 @@ static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
|
|||
}
|
||||
len /= 2;
|
||||
|
||||
rc = os_realloc(bss->roaming_consortium,
|
||||
sizeof(struct hostapd_roaming_consortium) *
|
||||
(bss->roaming_consortium_count + 1));
|
||||
rc = os_realloc_array(bss->roaming_consortium,
|
||||
bss->roaming_consortium_count + 1,
|
||||
sizeof(struct hostapd_roaming_consortium));
|
||||
if (rc == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -1293,9 +1293,8 @@ static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
|
|||
if (nlen > 252)
|
||||
goto fail;
|
||||
|
||||
vn = os_realloc(bss->venue_name,
|
||||
sizeof(struct hostapd_venue_name) *
|
||||
(bss->venue_name_count + 1));
|
||||
vn = os_realloc_array(bss->venue_name, bss->venue_name_count + 1,
|
||||
sizeof(struct hostapd_venue_name));
|
||||
if (vn == NULL)
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -795,8 +795,9 @@ static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
|
|||
ap_check_sa_query_timeout(hapd, sta))
|
||||
return;
|
||||
|
||||
nbuf = os_realloc(sta->sa_query_trans_id,
|
||||
(sta->sa_query_count + 1) * WLAN_SA_QUERY_TR_ID_LEN);
|
||||
nbuf = os_realloc_array(sta->sa_query_trans_id,
|
||||
sta->sa_query_count + 1,
|
||||
WLAN_SA_QUERY_TR_ID_LEN);
|
||||
if (nbuf == NULL)
|
||||
return;
|
||||
if (sta->sa_query_count == 0) {
|
||||
|
|
|
@ -23,7 +23,7 @@ int hostapd_register_probereq_cb(struct hostapd_data *hapd,
|
|||
{
|
||||
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));
|
||||
if (n == NULL)
|
||||
return -1;
|
||||
|
|
|
@ -1328,8 +1328,8 @@ wpa_driver_bsd_add_scan_entry(struct wpa_scan_results *res,
|
|||
|
||||
result->ie_len = pos - (u8 *)(result + 1);
|
||||
|
||||
tmp = os_realloc(res->res,
|
||||
(res->num + 1) * sizeof(struct wpa_scan_res *));
|
||||
tmp = os_realloc_array(res->res, res->num + 1,
|
||||
sizeof(struct wpa_scan_res *));
|
||||
if (tmp == NULL) {
|
||||
os_free(result);
|
||||
return;
|
||||
|
|
|
@ -3988,8 +3988,8 @@ static int bss_info_handler(struct nl_msg *msg, void *arg)
|
|||
return NL_SKIP;
|
||||
}
|
||||
|
||||
tmp = os_realloc(res->res,
|
||||
(res->num + 1) * sizeof(struct wpa_scan_res *));
|
||||
tmp = os_realloc_array(res->res, res->num + 1,
|
||||
sizeof(struct wpa_scan_res *));
|
||||
if (tmp == NULL) {
|
||||
os_free(r);
|
||||
return NL_SKIP;
|
||||
|
@ -4784,7 +4784,9 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
|
|||
return NL_SKIP;
|
||||
|
||||
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)
|
||||
return NL_SKIP;
|
||||
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)
|
||||
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)
|
||||
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
|
||||
old = NULL;
|
||||
|
||||
drv->if_indices = os_realloc(old,
|
||||
sizeof(int) * (drv->num_if_indices + 1));
|
||||
drv->if_indices = os_realloc_array(old, drv->num_if_indices + 1,
|
||||
sizeof(int));
|
||||
if (!drv->if_indices) {
|
||||
if (!old)
|
||||
drv->if_indices = drv->default_if_indices;
|
||||
|
|
|
@ -1414,8 +1414,8 @@ static void wpa_driver_wext_add_scan_entry(struct wpa_scan_results *res,
|
|||
if (data->ie)
|
||||
os_memcpy(pos, data->ie, data->ie_len);
|
||||
|
||||
tmp = os_realloc(res->res,
|
||||
(res->num + 1) * sizeof(struct wpa_scan_res *));
|
||||
tmp = os_realloc_array(res->res, res->num + 1,
|
||||
sizeof(struct wpa_scan_res *));
|
||||
if (tmp == NULL) {
|
||||
os_free(r);
|
||||
return;
|
||||
|
|
|
@ -946,8 +946,8 @@ int eap_peer_select_phase2_methods(struct eap_peer_config *config,
|
|||
"method '%s'", start);
|
||||
} else {
|
||||
num_methods++;
|
||||
_methods = os_realloc(methods,
|
||||
num_methods * sizeof(*methods));
|
||||
_methods = os_realloc_array(methods, num_methods,
|
||||
sizeof(*methods));
|
||||
if (_methods == NULL) {
|
||||
os_free(methods);
|
||||
os_free(buf);
|
||||
|
|
|
@ -52,7 +52,7 @@ struct p2p_group * p2p_group_init(struct p2p_data *p2p,
|
|||
if (group == 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 *));
|
||||
if (groups == NULL) {
|
||||
os_free(group);
|
||||
|
|
|
@ -562,8 +562,8 @@ static int radius_msg_add_attr_to_array(struct radius_msg *msg,
|
|||
size_t *nattr_pos;
|
||||
int nlen = msg->attr_size * 2;
|
||||
|
||||
nattr_pos = os_realloc(msg->attr_pos,
|
||||
nlen * sizeof(*msg->attr_pos));
|
||||
nattr_pos = os_realloc_array(msg->attr_pos, nlen,
|
||||
sizeof(*msg->attr_pos));
|
||||
if (nattr_pos == NULL)
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -281,8 +281,8 @@ int radius_client_register(struct radius_client_data *radius,
|
|||
num = &radius->num_auth_handlers;
|
||||
}
|
||||
|
||||
newh = os_realloc(*handlers,
|
||||
(*num + 1) * sizeof(struct radius_rx_handler));
|
||||
newh = os_realloc_array(*handlers, *num + 1,
|
||||
sizeof(struct radius_rx_handler));
|
||||
if (newh == NULL)
|
||||
return -1;
|
||||
|
||||
|
|
|
@ -153,8 +153,8 @@ static int eloop_sock_table_add_sock(struct eloop_sock_table *table,
|
|||
#ifdef CONFIG_ELOOP_POLL
|
||||
if (new_max_sock >= eloop.max_pollfd_map) {
|
||||
struct pollfd **nmap;
|
||||
nmap = os_realloc(eloop.pollfds_map, sizeof(struct pollfd *) *
|
||||
(new_max_sock + 50));
|
||||
nmap = os_realloc_array(eloop.pollfds_map, new_max_sock + 50,
|
||||
sizeof(struct pollfd *));
|
||||
if (nmap == NULL)
|
||||
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) {
|
||||
struct pollfd *n;
|
||||
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)
|
||||
return -1;
|
||||
|
||||
|
@ -175,9 +176,8 @@ static int eloop_sock_table_add_sock(struct eloop_sock_table *table,
|
|||
#endif /* CONFIG_ELOOP_POLL */
|
||||
|
||||
eloop_trace_sock_remove_ref(table);
|
||||
tmp = (struct eloop_sock *)
|
||||
os_realloc(table->table,
|
||||
(table->count + 1) * sizeof(struct eloop_sock));
|
||||
tmp = os_realloc_array(table->table, table->count + 1,
|
||||
sizeof(struct eloop_sock));
|
||||
if (tmp == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -639,9 +639,7 @@ int eloop_register_signal(int sig, eloop_signal_handler handler,
|
|||
{
|
||||
struct eloop_signal *tmp;
|
||||
|
||||
tmp = (struct eloop_signal *)
|
||||
os_realloc(eloop.signals,
|
||||
(eloop.signal_count + 1) *
|
||||
tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1,
|
||||
sizeof(struct eloop_signal));
|
||||
if (tmp == NULL)
|
||||
return -1;
|
||||
|
|
|
@ -98,8 +98,8 @@ static int eloop_prepare_handles(void)
|
|||
|
||||
if (eloop.num_handles > eloop.reader_count + eloop.event_count + 8)
|
||||
return 0;
|
||||
n = os_realloc(eloop.handles,
|
||||
eloop.num_handles * 2 * sizeof(eloop.handles[0]));
|
||||
n = os_realloc_array(eloop.handles, eloop.num_handles * 2,
|
||||
sizeof(eloop.handles[0]));
|
||||
if (n == NULL)
|
||||
return -1;
|
||||
eloop.handles = n;
|
||||
|
@ -128,8 +128,8 @@ int eloop_register_read_sock(int sock, eloop_sock_handler handler,
|
|||
WSACloseEvent(event);
|
||||
return -1;
|
||||
}
|
||||
tmp = os_realloc(eloop.readers,
|
||||
(eloop.reader_count + 1) * sizeof(struct eloop_sock));
|
||||
tmp = os_realloc_array(eloop.readers, eloop.reader_count + 1,
|
||||
sizeof(struct eloop_sock));
|
||||
if (tmp == NULL) {
|
||||
WSAEventSelect(sock, event, 0);
|
||||
WSACloseEvent(event);
|
||||
|
@ -191,8 +191,8 @@ int eloop_register_event(void *event, size_t event_size,
|
|||
if (eloop_prepare_handles())
|
||||
return -1;
|
||||
|
||||
tmp = os_realloc(eloop.events,
|
||||
(eloop.event_count + 1) * sizeof(struct eloop_event));
|
||||
tmp = os_realloc_array(eloop.events, eloop.event_count + 1,
|
||||
sizeof(struct eloop_event));
|
||||
if (tmp == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -392,8 +392,7 @@ int eloop_register_signal(int sig, eloop_signal_handler handler,
|
|||
{
|
||||
struct eloop_signal *tmp;
|
||||
|
||||
tmp = os_realloc(eloop.signals,
|
||||
(eloop.signal_count + 1) *
|
||||
tmp = os_realloc_array(eloop.signals, eloop.signal_count + 1,
|
||||
sizeof(struct eloop_signal));
|
||||
if (tmp == NULL)
|
||||
return -1;
|
||||
|
|
|
@ -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))
|
||||
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;
|
||||
|
||||
|
@ -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) {
|
||||
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;
|
||||
|
@ -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 "
|
||||
"%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;
|
||||
|
@ -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++) {
|
||||
if (modes[i].channels[j].flag & HOSTAPD_CHAN_DISABLED)
|
||||
continue;
|
||||
n = os_realloc(freqs, (count + 2) * sizeof(int));
|
||||
n = os_realloc_array(freqs, count + 2, sizeof(int));
|
||||
if (n == NULL)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -918,7 +918,7 @@ static int * wpa_config_parse_freqs(const struct parse_data *data,
|
|||
if (used == len) {
|
||||
int *n;
|
||||
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) {
|
||||
os_free(freqs);
|
||||
return NULL;
|
||||
|
@ -1047,8 +1047,8 @@ static int wpa_config_parse_eap(const struct parse_data *data,
|
|||
last = *end == '\0';
|
||||
*end = '\0';
|
||||
tmp = methods;
|
||||
methods = os_realloc(methods,
|
||||
(num_methods + 1) * sizeof(*methods));
|
||||
methods = os_realloc_array(methods, num_methods + 1,
|
||||
sizeof(*methods));
|
||||
if (methods == NULL) {
|
||||
os_free(tmp);
|
||||
os_free(buf);
|
||||
|
@ -1078,7 +1078,7 @@ static int wpa_config_parse_eap(const struct parse_data *data,
|
|||
os_free(buf);
|
||||
|
||||
tmp = methods;
|
||||
methods = os_realloc(methods, (num_methods + 1) * sizeof(*methods));
|
||||
methods = os_realloc_array(methods, num_methods + 1, sizeof(*methods));
|
||||
if (methods == NULL) {
|
||||
os_free(tmp);
|
||||
return -1;
|
||||
|
@ -1381,7 +1381,7 @@ static int wpa_config_parse_p2p_client_list(const struct parse_data *data,
|
|||
line, value);
|
||||
/* continue anyway */
|
||||
} else {
|
||||
n = os_realloc(buf, (count + 1) * ETH_ALEN);
|
||||
n = os_realloc_array(buf, count + 1, ETH_ALEN);
|
||||
if (n == NULL) {
|
||||
os_free(buf);
|
||||
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 */
|
||||
nlist = os_realloc(config->pssid,
|
||||
(config->num_prio + 1) * sizeof(struct wpa_ssid *));
|
||||
nlist = os_realloc_array(config->pssid, config->num_prio + 1,
|
||||
sizeof(struct wpa_ssid *));
|
||||
if (nlist == NULL)
|
||||
return -1;
|
||||
|
||||
|
@ -2869,7 +2869,8 @@ static int wpa_config_process_p2p_pref_chan(
|
|||
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)
|
||||
goto fail;
|
||||
pref = n;
|
||||
|
|
|
@ -133,7 +133,7 @@ static int set_bssid_filter(struct wpa_supplicant *wpa_s, char *val)
|
|||
os_free(filter);
|
||||
return -1;
|
||||
}
|
||||
n = os_realloc(filter, (count + 1) * ETH_ALEN);
|
||||
n = os_realloc_array(filter, count + 1, ETH_ALEN);
|
||||
if (n == NULL) {
|
||||
os_free(filter);
|
||||
return -1;
|
||||
|
@ -3618,8 +3618,8 @@ static int p2p_ctrl_disallow_freq(struct wpa_supplicant *wpa_s,
|
|||
*/
|
||||
pos = param;
|
||||
while (pos && pos[0]) {
|
||||
n = os_realloc(freq,
|
||||
(count + 1) * sizeof(struct wpa_freq_range));
|
||||
n = os_realloc_array(freq, count + 1,
|
||||
sizeof(struct wpa_freq_range));
|
||||
if (n == NULL) {
|
||||
os_free(freq);
|
||||
return -1;
|
||||
|
|
|
@ -738,7 +738,7 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
|
|||
entry->bytearray_value = NULL;
|
||||
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)
|
||||
return FALSE;
|
||||
|
||||
|
@ -748,8 +748,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
|
|||
char byte;
|
||||
|
||||
if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
|
||||
nbuffer = os_realloc(buffer, BYTE_ARRAY_ITEM_SIZE *
|
||||
(count + BYTE_ARRAY_CHUNK_SIZE));
|
||||
nbuffer = os_realloc_array(
|
||||
buffer, count + BYTE_ARRAY_CHUNK_SIZE,
|
||||
BYTE_ARRAY_ITEM_SIZE);
|
||||
if (nbuffer == NULL) {
|
||||
os_free(buffer);
|
||||
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->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)
|
||||
return FALSE;
|
||||
|
||||
|
@ -806,8 +807,9 @@ static dbus_bool_t _wpa_dbus_dict_entry_get_string_array(
|
|||
char *str;
|
||||
|
||||
if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
|
||||
nbuffer = os_realloc(buffer, STR_ARRAY_ITEM_SIZE *
|
||||
(count + STR_ARRAY_CHUNK_SIZE));
|
||||
nbuffer = os_realloc_array(
|
||||
buffer, count + STR_ARRAY_CHUNK_SIZE,
|
||||
STR_ARRAY_ITEM_SIZE);
|
||||
if (nbuffer == NULL) {
|
||||
os_free(buffer);
|
||||
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;
|
||||
|
||||
newbuf = os_realloc(entry->binarray_value,
|
||||
buflen * BIN_ARRAY_ITEM_SIZE);
|
||||
newbuf = os_realloc_array(entry->binarray_value,
|
||||
buflen, BIN_ARRAY_ITEM_SIZE);
|
||||
if (!newbuf)
|
||||
goto cleanup;
|
||||
entry->binarray_value = newbuf;
|
||||
|
|
|
@ -1159,8 +1159,9 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
|
|||
|
||||
#define FREQS_ALLOC_CHUNK 32
|
||||
if (freqs_num % FREQS_ALLOC_CHUNK == 0) {
|
||||
nfreqs = os_realloc(freqs, sizeof(int) *
|
||||
(freqs_num + FREQS_ALLOC_CHUNK));
|
||||
nfreqs = os_realloc_array(
|
||||
freqs, freqs_num + FREQS_ALLOC_CHUNK,
|
||||
sizeof(int));
|
||||
if (nfreqs == NULL)
|
||||
os_free(freqs);
|
||||
freqs = nfreqs;
|
||||
|
@ -1180,8 +1181,7 @@ static int wpas_dbus_get_scan_channels(DBusMessage *message,
|
|||
dbus_message_iter_next(&array_iter);
|
||||
}
|
||||
|
||||
nfreqs = os_realloc(freqs,
|
||||
sizeof(int) * (freqs_num + 1));
|
||||
nfreqs = os_realloc_array(freqs, freqs_num + 1, sizeof(int));
|
||||
if (nfreqs == NULL)
|
||||
os_free(freqs);
|
||||
freqs = nfreqs;
|
||||
|
|
|
@ -241,7 +241,7 @@ int main(int argc, char *argv[])
|
|||
break;
|
||||
case 'N':
|
||||
iface_count++;
|
||||
iface = os_realloc(ifaces, iface_count *
|
||||
iface = os_realloc_array(ifaces, iface_count,
|
||||
sizeof(struct wpa_interface));
|
||||
if (iface == NULL)
|
||||
goto out;
|
||||
|
|
|
@ -530,8 +530,8 @@ static void wpas_p2p_add_persistent_group_client(struct wpa_supplicant *wpa_s,
|
|||
return; /* already in list */
|
||||
}
|
||||
|
||||
n = os_realloc(s->p2p_client_list,
|
||||
(s->num_p2p_clients + 1) * ETH_ALEN);
|
||||
n = os_realloc_array(s->p2p_client_list, s->num_p2p_clients + 1,
|
||||
ETH_ALEN);
|
||||
if (n == NULL)
|
||||
return;
|
||||
os_memcpy(n + s->num_p2p_clients * ETH_ALEN, addr, ETH_ALEN);
|
||||
|
|
|
@ -138,7 +138,7 @@ static void int_array_concat(int **res, const int *a)
|
|||
reslen = int_array_len(*res);
|
||||
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) {
|
||||
os_free(*res);
|
||||
*res = NULL;
|
||||
|
|
|
@ -951,8 +951,8 @@ static void sme_sa_query_timer(void *eloop_ctx, void *timeout_ctx)
|
|||
sme_check_sa_query_timeout(wpa_s))
|
||||
return;
|
||||
|
||||
nbuf = os_realloc(wpa_s->sme.sa_query_trans_id,
|
||||
(wpa_s->sme.sa_query_count + 1) *
|
||||
nbuf = os_realloc_array(wpa_s->sme.sa_query_trans_id,
|
||||
wpa_s->sme.sa_query_count + 1,
|
||||
WLAN_SA_QUERY_TR_ID_LEN);
|
||||
if (nbuf == NULL)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue