aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2019-08-19 23:57:58 (GMT)
committerJouni Malinen <j@w1.fi>2019-08-19 23:57:58 (GMT)
commit9ce3bfaf47870c475567da028628733571bf2888 (patch)
treeb7e1e3c06793279b97a41c09f4d9d3fc007f2ae3
parentfa1f0751cc259dd76325556b8460864aa408cad9 (diff)
downloadhostap-9ce3bfaf47870c475567da028628733571bf2888.zip
hostap-9ce3bfaf47870c475567da028628733571bf2888.tar.gz
hostap-9ce3bfaf47870c475567da028628733571bf2888.tar.bz2
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>
-rw-r--r--src/radius/radius_server.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/src/radius/radius_server.c b/src/radius/radius_server.c
index c909f43..c17e53b 100644
--- a/src/radius/radius_server.c
+++ b/src/radius/radius_server.c
@@ -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) {
- 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;
- }
+ 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;
}