mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
Use os_calloc() instead of os_zalloc()
Automatic changes with spatch using the following semantic patch: @@ constant C; type T; @@ - os_zalloc(C*sizeof(T)) + os_calloc(C,sizeof(T)) @@ expression E; type T; @@ - os_zalloc((E)*sizeof(T)) + os_calloc(E,sizeof(T)) Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
33d0b1579b
commit
faebdeaa9e
@ -58,7 +58,7 @@ gas_dialog_create(struct hostapd_data *hapd, const u8 *addr, u8 dialog_token)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sta->gas_dialog == NULL) {
|
if (sta->gas_dialog == NULL) {
|
||||||
sta->gas_dialog = os_zalloc(GAS_DIALOG_MAX *
|
sta->gas_dialog = os_calloc(GAS_DIALOG_MAX,
|
||||||
sizeof(struct gas_dialog_info));
|
sizeof(struct gas_dialog_info));
|
||||||
if (sta->gas_dialog == NULL)
|
if (sta->gas_dialog == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1878,7 +1878,7 @@ static struct hostapd_iface * hostapd_data_alloc(
|
|||||||
hapd_iface->conf = conf;
|
hapd_iface->conf = conf;
|
||||||
hapd_iface->num_bss = conf->num_bss;
|
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 *));
|
sizeof(struct hostapd_data *));
|
||||||
if (hapd_iface->bss == NULL)
|
if (hapd_iface->bss == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -133,7 +133,7 @@ char ** eap_get_names_as_string_array(size_t *num)
|
|||||||
for (m = eap_methods; m; m = m->next)
|
for (m = eap_methods; m; m = m->next)
|
||||||
array_len++;
|
array_len++;
|
||||||
|
|
||||||
array = os_zalloc(sizeof(char *) * (array_len + 1));
|
array = os_calloc(array_len + 1, sizeof(char *));
|
||||||
if (array == NULL)
|
if (array == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ wpa_supplicant_build_filter_ssids(struct wpa_config *conf, size_t *num_ssids)
|
|||||||
}
|
}
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
ssids = os_zalloc(count * sizeof(struct wpa_driver_scan_filter));
|
ssids = os_calloc(count, sizeof(struct wpa_driver_scan_filter));
|
||||||
if (ssids == NULL)
|
if (ssids == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ static void wpa_supplicant_optimize_freqs(
|
|||||||
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO "
|
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO "
|
||||||
"preferred frequency %d MHz",
|
"preferred frequency %d MHz",
|
||||||
wpa_s->go_params->freq);
|
wpa_s->go_params->freq);
|
||||||
params->freqs = os_zalloc(2 * sizeof(int));
|
params->freqs = os_calloc(2, sizeof(int));
|
||||||
if (params->freqs)
|
if (params->freqs)
|
||||||
params->freqs[0] = wpa_s->go_params->freq;
|
params->freqs[0] = wpa_s->go_params->freq;
|
||||||
} else if (wpa_s->p2p_in_provisioning < 8 &&
|
} else if (wpa_s->p2p_in_provisioning < 8 &&
|
||||||
@ -346,7 +346,7 @@ static void wpa_supplicant_optimize_freqs(
|
|||||||
wpa_s->p2p_invite_go_freq > 0) {
|
wpa_s->p2p_invite_go_freq > 0) {
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO preferred frequency %d MHz during invitation",
|
wpa_dbg(wpa_s, MSG_DEBUG, "P2P: Scan only GO preferred frequency %d MHz during invitation",
|
||||||
wpa_s->p2p_invite_go_freq);
|
wpa_s->p2p_invite_go_freq);
|
||||||
params->freqs = os_zalloc(2 * sizeof(int));
|
params->freqs = os_calloc(2, sizeof(int));
|
||||||
if (params->freqs)
|
if (params->freqs)
|
||||||
params->freqs[0] = wpa_s->p2p_invite_go_freq;
|
params->freqs[0] = wpa_s->p2p_invite_go_freq;
|
||||||
}
|
}
|
||||||
@ -372,7 +372,7 @@ static void wpa_supplicant_optimize_freqs(
|
|||||||
*/
|
*/
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz "
|
wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz "
|
||||||
"that was used during provisioning", wpa_s->wps_freq);
|
"that was used during provisioning", wpa_s->wps_freq);
|
||||||
params->freqs = os_zalloc(2 * sizeof(int));
|
params->freqs = os_calloc(2, sizeof(int));
|
||||||
if (params->freqs)
|
if (params->freqs)
|
||||||
params->freqs[0] = wpa_s->wps_freq;
|
params->freqs[0] = wpa_s->wps_freq;
|
||||||
wpa_s->after_wps--;
|
wpa_s->after_wps--;
|
||||||
@ -384,7 +384,7 @@ static void wpa_supplicant_optimize_freqs(
|
|||||||
/* Optimize provisioning scan based on already known channel */
|
/* Optimize provisioning scan based on already known channel */
|
||||||
wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz",
|
wpa_dbg(wpa_s, MSG_DEBUG, "WPS: Scan only frequency %u MHz",
|
||||||
wpa_s->wps_freq);
|
wpa_s->wps_freq);
|
||||||
params->freqs = os_zalloc(2 * sizeof(int));
|
params->freqs = os_calloc(2, sizeof(int));
|
||||||
if (params->freqs)
|
if (params->freqs)
|
||||||
params->freqs[0] = wpa_s->wps_freq;
|
params->freqs[0] = wpa_s->wps_freq;
|
||||||
wpa_s->known_wps_freq = 0; /* only do this once */
|
wpa_s->known_wps_freq = 0; /* only do this once */
|
||||||
@ -533,7 +533,7 @@ static void wpa_setband_scan_freqs_list(struct wpa_supplicant *wpa_s,
|
|||||||
return;
|
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)
|
if (params->freqs == NULL)
|
||||||
return;
|
return;
|
||||||
for (count = 0, i = 0; i < mode->num_channels; i++) {
|
for (count = 0, i = 0; i < mode->num_channels; i++) {
|
||||||
@ -1151,7 +1151,7 @@ int wpa_supplicant_req_sched_scan(struct wpa_supplicant *wpa_s)
|
|||||||
os_memset(¶ms, 0, sizeof(params));
|
os_memset(¶ms, 0, sizeof(params));
|
||||||
|
|
||||||
/* If we can't allocate space for the filters, we just don't filter */
|
/* If we can't allocate space for the filters, we just don't filter */
|
||||||
params.filter_ssids = os_zalloc(wpa_s->max_match_sets *
|
params.filter_ssids = os_calloc(wpa_s->max_match_sets,
|
||||||
sizeof(struct wpa_driver_scan_filter));
|
sizeof(struct wpa_driver_scan_filter));
|
||||||
|
|
||||||
prev_state = wpa_s->wpa_state;
|
prev_state = wpa_s->wpa_state;
|
||||||
|
@ -854,8 +854,8 @@ static void ieee802_11_rx_bss_trans_mgmt_req(struct wpa_supplicant *wpa_s,
|
|||||||
|
|
||||||
wpa_msg(wpa_s, MSG_INFO, "WNM: Preferred List Available");
|
wpa_msg(wpa_s, MSG_INFO, "WNM: Preferred List Available");
|
||||||
wnm_deallocate_memory(wpa_s);
|
wnm_deallocate_memory(wpa_s);
|
||||||
wpa_s->wnm_neighbor_report_elements = os_zalloc(
|
wpa_s->wnm_neighbor_report_elements = os_calloc(
|
||||||
WNM_MAX_NEIGHBOR_REPORT *
|
WNM_MAX_NEIGHBOR_REPORT,
|
||||||
sizeof(struct neighbor_report));
|
sizeof(struct neighbor_report));
|
||||||
if (wpa_s->wnm_neighbor_report_elements == NULL)
|
if (wpa_s->wnm_neighbor_report_elements == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -4275,7 +4275,7 @@ struct wpa_global * wpa_supplicant_init(struct wpa_params *params)
|
|||||||
wpa_supplicant_deinit(global);
|
wpa_supplicant_deinit(global);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
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) {
|
if (global->drv_priv == NULL) {
|
||||||
wpa_supplicant_deinit(global);
|
wpa_supplicant_deinit(global);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -4434,7 +4434,7 @@ static int * get_bss_freqs_in_ess(struct wpa_supplicant *wpa_s)
|
|||||||
int *freqs;
|
int *freqs;
|
||||||
int num_freqs = 0;
|
int num_freqs = 0;
|
||||||
|
|
||||||
freqs = os_zalloc(sizeof(int) * (max_freqs + 1));
|
freqs = os_calloc(max_freqs + 1, sizeof(int));
|
||||||
if (freqs == NULL)
|
if (freqs == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user