RADIUS server: Abort startup on allocation failures
Be more consistent on checking all parameter allocation and copying steps within radius_server_init() and abort startup if anything fails instead of trying to continue with other parts of the configuration. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
fa1f0751cc
commit
9ce3bfaf47
1 changed files with 25 additions and 21 deletions
|
@ -2213,33 +2213,40 @@ radius_server_init(struct radius_server_conf *conf)
|
|||
data->get_eap_user = conf->get_eap_user;
|
||||
if (conf->eap_req_id_text) {
|
||||
data->eap_req_id_text = os_malloc(conf->eap_req_id_text_len);
|
||||
if (data->eap_req_id_text) {
|
||||
if (!data->eap_req_id_text)
|
||||
goto fail;
|
||||
os_memcpy(data->eap_req_id_text, conf->eap_req_id_text,
|
||||
conf->eap_req_id_text_len);
|
||||
data->eap_req_id_text_len = conf->eap_req_id_text_len;
|
||||
}
|
||||
}
|
||||
data->erp_domain = conf->erp_domain;
|
||||
|
||||
if (conf->subscr_remediation_url) {
|
||||
data->subscr_remediation_url =
|
||||
os_strdup(conf->subscr_remediation_url);
|
||||
if (!data->subscr_remediation_url)
|
||||
goto fail;
|
||||
}
|
||||
data->subscr_remediation_method = conf->subscr_remediation_method;
|
||||
if (conf->hs20_sim_provisioning_url)
|
||||
if (conf->hs20_sim_provisioning_url) {
|
||||
data->hs20_sim_provisioning_url =
|
||||
os_strdup(conf->hs20_sim_provisioning_url);
|
||||
if (!data->hs20_sim_provisioning_url)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (conf->t_c_server_url)
|
||||
if (conf->t_c_server_url) {
|
||||
data->t_c_server_url = os_strdup(conf->t_c_server_url);
|
||||
if (!data->t_c_server_url)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SQLITE
|
||||
if (conf->sqlite_file) {
|
||||
if (sqlite3_open(conf->sqlite_file, &data->db)) {
|
||||
RADIUS_ERROR("Could not open SQLite file '%s'",
|
||||
conf->sqlite_file);
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_SQLITE */
|
||||
|
@ -2253,8 +2260,7 @@ radius_server_init(struct radius_server_conf *conf)
|
|||
conf->ipv6);
|
||||
if (data->clients == NULL) {
|
||||
wpa_printf(MSG_ERROR, "No RADIUS clients configured");
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IPV6
|
||||
|
@ -2265,14 +2271,12 @@ radius_server_init(struct radius_server_conf *conf)
|
|||
data->auth_sock = radius_server_open_socket(conf->auth_port);
|
||||
if (data->auth_sock < 0) {
|
||||
wpa_printf(MSG_ERROR, "Failed to open UDP socket for RADIUS authentication server");
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
if (eloop_register_read_sock(data->auth_sock,
|
||||
radius_server_receive_auth,
|
||||
data, NULL)) {
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (conf->acct_port) {
|
||||
|
@ -2285,20 +2289,20 @@ radius_server_init(struct radius_server_conf *conf)
|
|||
data->acct_sock = radius_server_open_socket(conf->acct_port);
|
||||
if (data->acct_sock < 0) {
|
||||
wpa_printf(MSG_ERROR, "Failed to open UDP socket for RADIUS accounting server");
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
goto fail;
|
||||
}
|
||||
if (eloop_register_read_sock(data->acct_sock,
|
||||
radius_server_receive_acct,
|
||||
data, NULL)) {
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
}
|
||||
data, NULL))
|
||||
goto fail;
|
||||
} else {
|
||||
data->acct_sock = -1;
|
||||
}
|
||||
|
||||
return data;
|
||||
fail:
|
||||
radius_server_deinit(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue