From 3d32c6517dae078b4b9216e635d1d629fc715a77 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 14 Sep 2010 22:16:17 -1000 Subject: [PATCH] EAP-pwd: Fix couple of memory leaks --- src/eap_common/eap_pwd_common.c | 3 ++- src/eap_peer/eap_pwd.c | 9 ++++++++- src/eap_server/eap_server_pwd.c | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/eap_common/eap_pwd_common.c b/src/eap_common/eap_pwd_common.c index d01ba0a04..3dbe9e443 100644 --- a/src/eap_common/eap_pwd_common.c +++ b/src/eap_common/eap_pwd_common.c @@ -245,10 +245,11 @@ int compute_password_element(EAP_PWD_group *grp, u16 num, grp->group_num = num; if (0) { fail: + EC_GROUP_free(grp->group); EC_POINT_free(grp->pwe); BN_free(grp->order); BN_free(grp->prime); - free(grp); + os_free(grp); grp = NULL; ret = 1; } diff --git a/src/eap_peer/eap_pwd.c b/src/eap_peer/eap_pwd.c index 42a849fb3..3baca1568 100644 --- a/src/eap_peer/eap_pwd.c +++ b/src/eap_peer/eap_pwd.c @@ -142,8 +142,15 @@ static void eap_pwd_deinit(struct eap_sm *sm, void *priv) EC_POINT_free(data->my_element); EC_POINT_free(data->server_element); os_free(data->id_peer); + os_free(data->id_server); os_free(data->password); - os_free(data->grp); + if (data->grp) { + EC_GROUP_free(data->grp->group); + EC_POINT_free(data->grp->pwe); + BN_free(data->grp->order); + BN_free(data->grp->prime); + os_free(data->grp); + } os_free(data); } diff --git a/src/eap_server/eap_server_pwd.c b/src/eap_server/eap_server_pwd.c index 65b94c727..512817b6f 100644 --- a/src/eap_server/eap_server_pwd.c +++ b/src/eap_server/eap_server_pwd.c @@ -100,7 +100,7 @@ static void * eap_pwd_init(struct eap_sm *sm) data->password = os_malloc(sm->user->password_len); if (data->password == NULL) { - wpa_printf(MSG_INFO, "EAP-PWD: Mmemory allocation password " + wpa_printf(MSG_INFO, "EAP-PWD: Memory allocation password " "fail"); os_free(data->id_server); os_free(data); @@ -135,7 +135,14 @@ static void eap_pwd_reset(struct eap_sm *sm, void *priv) EC_POINT_free(data->peer_element); os_free(data->id_peer); os_free(data->id_server); - os_free(data->grp); + os_free(data->password); + if (data->grp) { + EC_GROUP_free(data->grp->group); + EC_POINT_free(data->grp->pwe); + BN_free(data->grp->order); + BN_free(data->grp->prime); + os_free(data->grp); + } os_free(data); }