aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2012-04-01 14:55:20 (GMT)
committerJouni Malinen <j@w1.fi>2012-04-01 14:55:20 (GMT)
commitca8e039fec1352e2ece4fdbd6fde92fd461565a3 (patch)
tree6891cb10ef25a9c85dedb2f00df04d285983a78d
parent8c6f80e02345f628aff7183df4532144848a30f7 (diff)
downloadhostap-ca8e039fec1352e2ece4fdbd6fde92fd461565a3.zip
hostap-ca8e039fec1352e2ece4fdbd6fde92fd461565a3.tar.gz
hostap-ca8e039fec1352e2ece4fdbd6fde92fd461565a3.tar.bz2
Fix memory leaks on radius_client_send error paths
In case this function returns an error, the RADIUS message needs to freed in the caller. Signed-hostap: Jouni Malinen <j@w1.fi>
-rw-r--r--radius_example/radius_example.c3
-rw-r--r--src/ap/accounting.c15
-rw-r--r--src/ap/ieee802_11_auth.c3
-rw-r--r--wpa_supplicant/eapol_test.c4
4 files changed, 16 insertions, 9 deletions
diff --git a/radius_example/radius_example.c b/radius_example/radius_example.c
index 066707f..cb0e154 100644
--- a/radius_example/radius_example.c
+++ b/radius_example/radius_example.c
@@ -88,7 +88,8 @@ static void start_example(void *eloop_ctx, void *timeout_ctx)
return;
}
- radius_client_send(ctx->radius, msg, RADIUS_AUTH, NULL);
+ if (radius_client_send(ctx->radius, msg, RADIUS_AUTH, NULL) < 0)
+ radius_msg_free(msg);
}
diff --git a/src/ap/accounting.c b/src/ap/accounting.c
index 2a04560..edda88b 100644
--- a/src/ap/accounting.c
+++ b/src/ap/accounting.c
@@ -259,8 +259,9 @@ void accounting_sta_start(struct hostapd_data *hapd, struct sta_info *sta)
hapd, sta);
msg = accounting_msg(hapd, sta, RADIUS_ACCT_STATUS_TYPE_START);
- if (msg)
- radius_client_send(hapd->radius, msg, RADIUS_ACCT, sta->addr);
+ if (msg &&
+ radius_client_send(hapd->radius, msg, RADIUS_ACCT, sta->addr) < 0)
+ radius_msg_free(msg);
sta->acct_session_started = 1;
}
@@ -358,9 +359,10 @@ static void accounting_sta_report(struct hostapd_data *hapd,
goto fail;
}
- radius_client_send(hapd->radius, msg,
- stop ? RADIUS_ACCT : RADIUS_ACCT_INTERIM,
- sta->addr);
+ if (radius_client_send(hapd->radius, msg,
+ stop ? RADIUS_ACCT : RADIUS_ACCT_INTERIM,
+ sta->addr) < 0)
+ goto fail;
return;
fail:
@@ -463,7 +465,8 @@ static void accounting_report_state(struct hostapd_data *hapd, int on)
return;
}
- radius_client_send(hapd->radius, msg, RADIUS_ACCT, NULL);
+ if (radius_client_send(hapd->radius, msg, RADIUS_ACCT, NULL) < 0)
+ radius_msg_free(msg);
}
diff --git a/src/ap/ieee802_11_auth.c b/src/ap/ieee802_11_auth.c
index 109c4bc..27b0789 100644
--- a/src/ap/ieee802_11_auth.c
+++ b/src/ap/ieee802_11_auth.c
@@ -193,7 +193,8 @@ static int hostapd_radius_acl_query(struct hostapd_data *hapd, const u8 *addr,
goto fail;
}
- radius_client_send(hapd->radius, msg, RADIUS_AUTH, addr);
+ if (radius_client_send(hapd->radius, msg, RADIUS_AUTH, addr) < 0)
+ goto fail;
return 0;
fail:
diff --git a/wpa_supplicant/eapol_test.c b/wpa_supplicant/eapol_test.c
index e92dc12..e53e156 100644
--- a/wpa_supplicant/eapol_test.c
+++ b/wpa_supplicant/eapol_test.c
@@ -278,7 +278,9 @@ static void ieee802_1x_encapsulate_radius(struct eapol_test_data *e,
}
}
- radius_client_send(e->radius, msg, RADIUS_AUTH, e->wpa_s->own_addr);
+ if (radius_client_send(e->radius, msg, RADIUS_AUTH, e->wpa_s->own_addr)
+ < 0)
+ goto fail;
return;
fail: