aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hostapd/main.c8
-rw-r--r--src/ap/hw_features.c4
-rw-r--r--src/ap/ieee802_1x.c2
-rw-r--r--src/drivers/driver_ndis.c2
-rw-r--r--src/drivers/driver_nl80211.c5
-rw-r--r--src/drivers/driver_privsep.c2
-rw-r--r--src/drivers/driver_test.c18
-rw-r--r--src/radius/radius.c6
-rw-r--r--wlantest/wlantest_cli.c24
-rw-r--r--wpa_supplicant/ap.c2
-rw-r--r--wpa_supplicant/config.c4
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers.c6
-rw-r--r--wpa_supplicant/dbus/dbus_new_handlers_p2p.c6
-rw-r--r--wpa_supplicant/interworking.c4
-rw-r--r--wpa_supplicant/sme.c2
-rw-r--r--wpa_supplicant/wpa_cli.c4
16 files changed, 49 insertions, 50 deletions
diff --git a/hostapd/main.c b/hostapd/main.c
index 3826ccf..35b4da9 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -181,7 +181,7 @@ static struct hostapd_iface * hostapd_init(const char *config_file)
hapd_iface->conf = conf;
hapd_iface->num_bss = conf->num_bss;
- hapd_iface->bss = os_zalloc(conf->num_bss *
+ hapd_iface->bss = os_calloc(conf->num_bss,
sizeof(struct hostapd_data *));
if (hapd_iface->bss == NULL)
goto fail;
@@ -254,7 +254,7 @@ static int hostapd_driver_init(struct hostapd_iface *iface)
params.use_pae_group_addr = hapd->conf->use_pae_group_addr;
params.num_bridge = hapd->iface->num_bss;
- params.bridge = os_zalloc(hapd->iface->num_bss * sizeof(char *));
+ params.bridge = os_calloc(hapd->iface->num_bss, sizeof(char *));
if (params.bridge == NULL)
return -1;
for (i = 0; i < hapd->iface->num_bss; i++) {
@@ -411,7 +411,7 @@ static int hostapd_global_init(struct hapd_interfaces *interfaces,
wpa_printf(MSG_ERROR, "No drivers enabled");
return -1;
}
- global.drv_priv = os_zalloc(global.drv_count * sizeof(void *));
+ global.drv_priv = os_calloc(global.drv_count, sizeof(void *));
if (global.drv_priv == NULL)
return -1;
@@ -592,7 +592,7 @@ int main(int argc, char *argv[])
wpa_debug_open_file(log_file);
interfaces.count = argc - optind;
- interfaces.iface = os_zalloc(interfaces.count *
+ interfaces.iface = os_calloc(interfaces.count,
sizeof(struct hostapd_iface *));
if (interfaces.iface == NULL) {
wpa_printf(MSG_ERROR, "malloc failed");
diff --git a/src/ap/hw_features.c b/src/ap/hw_features.c
index 76c4211..76aff77 100644
--- a/src/ap/hw_features.c
+++ b/src/ap/hw_features.c
@@ -138,7 +138,7 @@ int hostapd_prepare_rates(struct hostapd_iface *iface,
iface->num_rates = 0;
iface->current_rates =
- os_zalloc(mode->num_rates * sizeof(struct hostapd_rate_data));
+ os_calloc(mode->num_rates, sizeof(struct hostapd_rate_data));
if (!iface->current_rates) {
wpa_printf(MSG_ERROR, "Failed to allocate memory for rate "
"table.");
@@ -470,7 +470,7 @@ static void ieee80211n_scan_channels_2g4(struct hostapd_iface *iface,
affected_start, affected_end);
mode = iface->current_mode;
- params->freqs = os_zalloc((mode->num_channels + 1) * sizeof(int));
+ params->freqs = os_calloc(mode->num_channels + 1, sizeof(int));
if (params->freqs == NULL)
return;
pos = 0;
diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index f76860e..d4c3e48 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -1205,7 +1205,7 @@ static void ieee802_1x_store_radius_class(struct hostapd_data *hapd,
if (count <= 0)
return;
- nclass = os_zalloc(count * sizeof(struct radius_attr_data));
+ nclass = os_calloc(count, sizeof(struct radius_attr_data));
if (nclass == NULL)
return;
diff --git a/src/drivers/driver_ndis.c b/src/drivers/driver_ndis.c
index 185ed4f..b9e096c 100644
--- a/src/drivers/driver_ndis.c
+++ b/src/drivers/driver_ndis.c
@@ -858,7 +858,7 @@ static struct wpa_scan_results * wpa_driver_ndis_get_scan_results(void *priv)
os_free(b);
return NULL;
}
- results->res = os_zalloc(count * sizeof(struct wpa_scan_res *));
+ results->res = os_calloc(count, sizeof(struct wpa_scan_res *));
if (results->res == NULL) {
os_free(results);
os_free(b);
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index f560aff..211a15a 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4843,7 +4843,8 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
mode->num_channels++;
}
- mode->channels = os_zalloc(mode->num_channels * sizeof(struct hostapd_channel_data));
+ mode->channels = os_calloc(mode->num_channels,
+ sizeof(struct hostapd_channel_data));
if (!mode->channels)
return NL_SKIP;
@@ -4905,7 +4906,7 @@ static int phy_info_handler(struct nl_msg *msg, void *arg)
mode->num_rates++;
}
- mode->rates = os_zalloc(mode->num_rates * sizeof(int));
+ mode->rates = os_calloc(mode->num_rates, sizeof(int));
if (!mode->rates)
return NL_SKIP;
diff --git a/src/drivers/driver_privsep.c b/src/drivers/driver_privsep.c
index c8916f0..9481cbf 100644
--- a/src/drivers/driver_privsep.c
+++ b/src/drivers/driver_privsep.c
@@ -152,7 +152,7 @@ wpa_driver_privsep_get_scan_results2(void *priv)
return NULL;
}
- results->res = os_zalloc(num * sizeof(struct wpa_scan_res *));
+ results->res = os_calloc(num, sizeof(struct wpa_scan_res *));
if (results->res == NULL) {
os_free(results);
os_free(buf);
diff --git a/src/drivers/driver_test.c b/src/drivers/driver_test.c
index f011651..7a96b9b 100644
--- a/src/drivers/driver_test.c
+++ b/src/drivers/driver_test.c
@@ -1478,7 +1478,7 @@ static struct wpa_scan_results * wpa_driver_test_get_scan_results2(void *priv)
if (res == NULL)
return NULL;
- res->res = os_zalloc(drv->num_scanres * sizeof(struct wpa_scan_res *));
+ res->res = os_calloc(drv->num_scanres, sizeof(struct wpa_scan_res *));
if (res->res == NULL) {
os_free(res);
return NULL;
@@ -2570,15 +2570,14 @@ wpa_driver_test_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
*num_modes = 3;
*flags = 0;
- modes = os_zalloc(*num_modes * sizeof(struct hostapd_hw_modes));
+ modes = os_calloc(*num_modes, sizeof(struct hostapd_hw_modes));
if (modes == NULL)
return NULL;
modes[0].mode = HOSTAPD_MODE_IEEE80211G;
modes[0].num_channels = 11;
modes[0].num_rates = 12;
- modes[0].channels =
- os_zalloc(11 * sizeof(struct hostapd_channel_data));
- modes[0].rates = os_zalloc(modes[0].num_rates * sizeof(int));
+ modes[0].channels = os_calloc(11, sizeof(struct hostapd_channel_data));
+ modes[0].rates = os_calloc(modes[0].num_rates, sizeof(int));
if (modes[0].channels == NULL || modes[0].rates == NULL)
goto fail;
for (i = 0; i < 11; i++) {
@@ -2602,9 +2601,8 @@ wpa_driver_test_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
modes[1].mode = HOSTAPD_MODE_IEEE80211B;
modes[1].num_channels = 11;
modes[1].num_rates = 4;
- modes[1].channels =
- os_zalloc(11 * sizeof(struct hostapd_channel_data));
- modes[1].rates = os_zalloc(modes[1].num_rates * sizeof(int));
+ modes[1].channels = os_calloc(11, sizeof(struct hostapd_channel_data));
+ modes[1].rates = os_calloc(modes[1].num_rates, sizeof(int));
if (modes[1].channels == NULL || modes[1].rates == NULL)
goto fail;
for (i = 0; i < 11; i++) {
@@ -2620,8 +2618,8 @@ wpa_driver_test_get_hw_feature_data(void *priv, u16 *num_modes, u16 *flags)
modes[2].mode = HOSTAPD_MODE_IEEE80211A;
modes[2].num_channels = 1;
modes[2].num_rates = 8;
- modes[2].channels = os_zalloc(sizeof(struct hostapd_channel_data));
- modes[2].rates = os_zalloc(modes[2].num_rates * sizeof(int));
+ modes[2].channels = os_calloc(1, sizeof(struct hostapd_channel_data));
+ modes[2].rates = os_calloc(modes[2].num_rates, sizeof(int));
if (modes[2].channels == NULL || modes[2].rates == NULL)
goto fail;
modes[2].channels[0].chan = 60;
diff --git a/src/radius/radius.c b/src/radius/radius.c
index ace3974..858367c 100644
--- a/src/radius/radius.c
+++ b/src/radius/radius.c
@@ -78,8 +78,8 @@ static void radius_msg_set_hdr(struct radius_msg *msg, u8 code, u8 identifier)
static int radius_msg_initialize(struct radius_msg *msg)
{
- msg->attr_pos =
- os_zalloc(RADIUS_DEFAULT_ATTR_COUNT * sizeof(*msg->attr_pos));
+ msg->attr_pos = os_calloc(RADIUS_DEFAULT_ATTR_COUNT,
+ sizeof(*msg->attr_pos));
if (msg->attr_pos == NULL)
return -1;
@@ -1534,7 +1534,7 @@ int radius_copy_class(struct radius_class_data *dst,
if (src->attr == NULL)
return 0;
- dst->attr = os_zalloc(src->count * sizeof(struct radius_attr_data));
+ dst->attr = os_calloc(src->count, sizeof(struct radius_attr_data));
if (dst->attr == NULL)
return -1;
diff --git a/wlantest/wlantest_cli.c b/wlantest/wlantest_cli.c
index a417b3c..9ce4545 100644
--- a/wlantest/wlantest_cli.c
+++ b/wlantest/wlantest_cli.c
@@ -170,7 +170,7 @@ static char ** get_bssid_list(int s)
if (bssid == NULL)
return NULL;
- res = os_zalloc((len / ETH_ALEN + 1) * sizeof(char *));
+ res = os_calloc(len / ETH_ALEN + 1, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; i < len / ETH_ALEN; i++) {
@@ -208,7 +208,7 @@ static char ** get_sta_list(int s, const u8 *bssid, int add_bcast)
if (addr == NULL)
return NULL;
- res = os_zalloc((len / ETH_ALEN + 1 + add_bcast) * sizeof(char *));
+ res = os_calloc(len / ETH_ALEN + 1 + add_bcast, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; i < len / ETH_ALEN; i++) {
@@ -623,7 +623,7 @@ static char ** complete_get_sta_counter(int s, const char *str, int pos)
case 1:
/* counter list */
count = sizeof(sta_counters) / sizeof(sta_counters[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; sta_counters[i].name; i++) {
@@ -722,7 +722,7 @@ static char ** complete_get_bss_counter(int s, const char *str, int pos)
case 1:
/* counter list */
count = sizeof(bss_counters) / sizeof(bss_counters[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; bss_counters[i].name; i++) {
@@ -836,7 +836,7 @@ static char ** complete_get_tdls_counter(int s, const char *str, int pos)
case 1:
/* counter list */
count = sizeof(tdls_counters) / sizeof(tdls_counters[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; tdls_counters[i].name; i++) {
@@ -972,7 +972,7 @@ static char ** complete_inject(int s, const char *str, int pos)
case 1:
/* frame list */
count = sizeof(inject_frames) / sizeof(inject_frames[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
break;
for (i = 0; inject_frames[i].name; i++) {
@@ -982,7 +982,7 @@ static char ** complete_inject(int s, const char *str, int pos)
}
break;
case 2:
- res = os_zalloc(5 * sizeof(char *));
+ res = os_calloc(5, sizeof(char *));
if (res == NULL)
break;
res[0] = os_strdup("normal");
@@ -999,7 +999,7 @@ static char ** complete_inject(int s, const char *str, int pos)
break;
break;
case 3:
- res = os_zalloc(3 * sizeof(char *));
+ res = os_calloc(3, sizeof(char *));
if (res == NULL)
break;
res[0] = os_strdup("ap");
@@ -1122,7 +1122,7 @@ static char ** complete_send(int s, const char *str, int pos)
switch (arg) {
case 1:
- res = os_zalloc(5 * sizeof(char *));
+ res = os_calloc(5, sizeof(char *));
if (res == NULL)
break;
res[0] = os_strdup("normal");
@@ -1299,7 +1299,7 @@ static char ** complete_info_sta(int s, const char *str, int pos)
case 1:
/* counter list */
count = sizeof(sta_infos) / sizeof(sta_infos[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; sta_infos[i].name; i++) {
@@ -1404,7 +1404,7 @@ static char ** complete_info_bss(int s, const char *str, int pos)
case 1:
/* counter list */
count = sizeof(bss_infos) / sizeof(bss_infos[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
for (i = 0; bss_infos[i].name; i++) {
@@ -1584,7 +1584,7 @@ static char ** wlantest_cli_cmd_list(void)
count = sizeof(wlantest_cli_commands) /
sizeof(wlantest_cli_commands[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c
index 6179482..948e2e4 100644
--- a/wpa_supplicant/ap.c
+++ b/wpa_supplicant/ap.c
@@ -514,7 +514,7 @@ int wpa_supplicant_create_ap(struct wpa_supplicant *wpa_s,
#endif /* CONFIG_P2P */
hapd_iface->num_bss = conf->num_bss;
- hapd_iface->bss = os_zalloc(conf->num_bss *
+ hapd_iface->bss = os_calloc(conf->num_bss,
sizeof(struct hostapd_data *));
if (hapd_iface->bss == NULL) {
wpa_supplicant_ap_deinit(wpa_s);
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c
index aeb6aba..18d74bc 100644
--- a/wpa_supplicant/config.c
+++ b/wpa_supplicant/config.c
@@ -907,7 +907,7 @@ static int * wpa_config_parse_freqs(const struct parse_data *data,
used = 0;
len = 10;
- freqs = os_zalloc((len + 1) * sizeof(int));
+ freqs = os_calloc(len + 1, sizeof(int));
if (freqs == NULL)
return NULL;
@@ -2107,7 +2107,7 @@ char ** wpa_config_get_all(struct wpa_ssid *ssid, int get_keys)
get_keys = get_keys && ssid->export_keys;
- props = os_zalloc(sizeof(char *) * ((2 * NUM_SSID_FIELDS) + 1));
+ props = os_calloc(2 * NUM_SSID_FIELDS + 1, sizeof(char *));
if (!props)
return NULL;
diff --git a/wpa_supplicant/dbus/dbus_new_handlers.c b/wpa_supplicant/dbus/dbus_new_handlers.c
index cbe821a..1b54d5d 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers.c
@@ -871,7 +871,7 @@ dbus_bool_t wpas_dbus_getter_interfaces(DBusMessageIter *iter,
for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
num++;
- paths = os_zalloc(num * sizeof(char*));
+ paths = os_calloc(num, sizeof(char *));
if (!paths) {
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
return FALSE;
@@ -2787,7 +2787,7 @@ dbus_bool_t wpas_dbus_getter_bsss(DBusMessageIter *iter, DBusError *error,
unsigned int i = 0;
dbus_bool_t success = FALSE;
- paths = os_zalloc(wpa_s->num_bss * sizeof(char *));
+ paths = os_calloc(wpa_s->num_bss, sizeof(char *));
if (!paths) {
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
return FALSE;
@@ -2850,7 +2850,7 @@ dbus_bool_t wpas_dbus_getter_networks(DBusMessageIter *iter, DBusError *error,
if (!network_is_persistent_group(ssid))
num++;
- paths = os_zalloc(num * sizeof(char *));
+ paths = os_calloc(num, sizeof(char *));
if (!paths) {
dbus_set_error(error, DBUS_ERROR_NO_MEMORY, "no memory");
return FALSE;
diff --git a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
index f4541f7..3d31c89 100644
--- a/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
+++ b/wpa_supplicant/dbus/dbus_new_handlers_p2p.c
@@ -1049,7 +1049,7 @@ dbus_bool_t wpas_dbus_getter_p2p_peers(DBusMessageIter *iter, DBusError *error,
* Now construct the peer object paths in a form suitable for
* array_property_getter helper below.
*/
- peer_obj_paths = os_zalloc(num * sizeof(char *));
+ peer_obj_paths = os_calloc(num, sizeof(char *));
if (!peer_obj_paths) {
out_of_mem = 1;
@@ -1509,7 +1509,7 @@ dbus_bool_t wpas_dbus_getter_persistent_groups(DBusMessageIter *iter,
if (network_is_persistent_group(ssid))
num++;
- paths = os_zalloc(num * sizeof(char *));
+ paths = os_calloc(num, sizeof(char *));
if (!paths) {
dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, "no memory");
return FALSE;
@@ -1816,7 +1816,7 @@ dbus_bool_t wpas_dbus_getter_p2p_group_members(DBusMessageIter *iter,
num_members = p2p_get_group_num_members(wpa_s->p2p_group);
- paths = os_zalloc(num_members * sizeof(char *));
+ paths = os_calloc(num_members, sizeof(char *));
if (!paths)
goto out_of_memory;
diff --git a/wpa_supplicant/interworking.c b/wpa_supplicant/interworking.c
index ebc668b..ea720d2 100644
--- a/wpa_supplicant/interworking.c
+++ b/wpa_supplicant/interworking.c
@@ -330,7 +330,7 @@ static const u8 * nai_realm_parse_realm(struct nai_realm *r, const u8 *pos,
wpa_printf(MSG_DEBUG, "No room for EAP Methods");
return NULL;
}
- r->eap = os_zalloc(r->eap_count * sizeof(struct nai_realm_eap));
+ r->eap = os_calloc(r->eap_count, sizeof(struct nai_realm_eap));
if (r->eap == NULL)
return NULL;
@@ -366,7 +366,7 @@ static struct nai_realm * nai_realm_parse(struct wpabuf *anqp, u16 *count)
return NULL;
}
- realm = os_zalloc(num * sizeof(struct nai_realm));
+ realm = os_calloc(num, sizeof(struct nai_realm));
if (realm == NULL)
return NULL;
diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c
index a82cb95..4338728 100644
--- a/wpa_supplicant/sme.c
+++ b/wpa_supplicant/sme.c
@@ -802,7 +802,7 @@ static void wpa_setband_scan_freqs_list(struct wpa_supplicant *wpa_s,
return;
}
- params->freqs = os_zalloc((mode->num_channels + 1) * sizeof(int));
+ params->freqs = os_calloc(mode->num_channels + 1, sizeof(int));
if (params->freqs == NULL)
return;
for (count = 0, i = 0; i < mode->num_channels; i++) {
diff --git a/wpa_supplicant/wpa_cli.c b/wpa_supplicant/wpa_cli.c
index ec84be2..e9c0b9c 100644
--- a/wpa_supplicant/wpa_cli.c
+++ b/wpa_supplicant/wpa_cli.c
@@ -240,7 +240,7 @@ static char ** cli_txt_list_array(struct dl_list *txt_list)
char **res;
struct cli_txt_entry *e;
- res = os_zalloc((count + 1) * sizeof(char *));
+ res = os_calloc(count + 1, sizeof(char *));
if (res == NULL)
return NULL;
@@ -3392,7 +3392,7 @@ static char ** wpa_list_cmd_list(void)
int i, count;
count = sizeof(wpa_cli_commands) / sizeof(wpa_cli_commands[0]);
- res = os_zalloc(count * sizeof(char *));
+ res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;