fix freeing eap_handler as opaque (and typo)
Ken-ichirou MATSUZAWA
chamas at h4.dion.ne.jp
Tue Feb 8 13:19:10 CET 2011
Hello,
I hope this would be hint for fixing segfault and
better solution.
Thanks.
Subject: [PATCH 1/2] freeing EAP opaque with one arg
---
src/modules/rlm_eap/eap.h | 1 +
src/modules/rlm_eap/mem.c | 8 ++++++++
src/modules/rlm_eap/rlm_eap.c | 6 ++++--
src/modules/rlm_eap/rlm_eap.h | 1 +
4 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/modules/rlm_eap/eap.h b/src/modules/rlm_eap/eap.h
index 0150ef2..6d845ad 100644
--- a/src/modules/rlm_eap/eap.h
+++ b/src/modules/rlm_eap/eap.h
@@ -107,6 +107,7 @@ typedef struct _eap_handler {
void *opaque;
void (*free_opaque)(void *opaque);
+ void *inst_holder;
int status;
diff --git a/src/modules/rlm_eap/mem.c b/src/modules/rlm_eap/mem.c
index c5a5973..e702b19 100644
--- a/src/modules/rlm_eap/mem.c
+++ b/src/modules/rlm_eap/mem.c
@@ -136,6 +136,14 @@ EAP_HANDLER *eap_handler_alloc(rlm_eap_t *inst)
return handler;
}
+void eap_opaque_free(EAP_HANDLER *handler)
+{
+ if (!handler)
+ return;
+
+ eap_handler_free(handler->inst_holder, handler);
+}
+
void eap_handler_free(rlm_eap_t *inst, EAP_HANDLER *handler)
{
if (!handler)
diff --git a/src/modules/rlm_eap/rlm_eap.c b/src/modules/rlm_eap/rlm_eap.c
index 5cc74bc..c91bd0e 100644
--- a/src/modules/rlm_eap/rlm_eap.c
+++ b/src/modules/rlm_eap/rlm_eap.c
@@ -347,10 +347,11 @@ static int eap_authenticate(void *instance, REQUEST *request)
* can retrieve it in the post-proxy stage, and
* send a response.
*/
+ handler->inst_holder = inst;
rcode = request_data_add(request,
inst, REQUEST_DATA_EAP_HANDLER,
handler,
- (void *) eap_handler_free);
+ (void *) eap_opaque_free);
rad_assert(rcode == 0);
return RLM_MODULE_HANDLED;
@@ -372,10 +373,11 @@ static int eap_authenticate(void *instance, REQUEST *request)
* can retrieve it in the post-proxy stage, and
* send a response.
*/
+ handler->inst_holder = inst;
rcode = request_data_add(request,
inst, REQUEST_DATA_EAP_HANDLER,
handler,
- (void *) eap_handler_free);
+ (void *) eap_opaque_free);
rad_assert(rcode == 0);
/*
diff --git a/src/modules/rlm_eap/rlm_eap.h b/src/modules/rlm_eap/rlm_eap.h
index 84b4b50..0de2ae6 100644
--- a/src/modules/rlm_eap/rlm_eap.h
+++ b/src/modules/rlm_eap/rlm_eap.h
@@ -105,6 +105,7 @@ EAP_DS *eap_ds_alloc(void);
EAP_HANDLER *eap_handler_alloc(rlm_eap_t *inst);
void eap_packet_free(EAP_PACKET **eap_packet);
void eap_ds_free(EAP_DS **eap_ds);
+void eap_opaque_free(EAP_HANDLER *handler);
void eap_handler_free(rlm_eap_t *inst, EAP_HANDLER *handler);
int eaplist_add(rlm_eap_t *inst, EAP_HANDLER *handler);
--
Subject: [PATCH 2/2] fix typo
---
src/modules/rlm_eap/types/rlm_eap_peap/peap.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c
index b77d647..0d9a031 100644
--- a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c
+++ b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c
@@ -1133,8 +1133,8 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session)
request->proxy = fake->packet;
memset(&request->proxy->src_ipaddr, 0,
sizeof(request->proxy->src_ipaddr));
- memset(&request->proxy->src_ipaddr, 0,
- sizeof(request->proxy->src_ipaddr));
+ memset(&request->proxy->dst_ipaddr, 0,
+ sizeof(request->proxy->dst_ipaddr));
request->proxy->src_port = 0;
request->proxy->dst_port = 0;
fake->packet = NULL;
--
More information about the Freeradius-Users
mailing list