From: Arran Cudbard-Bell Date: Tue, 30 Jan 2018 02:04:09 +0000 (-0700) Subject: Explicitly free rctx X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a14ccac701b36eeda4c56a5cd062fa6d0e451c8c;p=thirdparty%2Ffreeradius-server.git Explicitly free rctx Else we'd leak memory into the REQUEST * --- diff --git a/src/include/modules.h b/src/include/modules.h index d5f5a354523..a42ca553fc8 100644 --- a/src/include/modules.h +++ b/src/include/modules.h @@ -309,12 +309,6 @@ int unlang_event_timeout_delete(REQUEST *request, void const *ctx); int unlang_event_fd_delete(REQUEST *request, void const *ctx, int fd); -rlm_rcode_t module_unlang_push_function(REQUEST *request, - unlang_function_t func, - unlang_function_t repeat, - fr_module_unlang_resume_t resume, - fr_module_unlang_signal_t signal, void *rctx); - rlm_rcode_t module_unlang_push_xlat(TALLOC_CTX *ctx, fr_value_box_t **out, REQUEST *request, xlat_exp_t const *xlat, fr_module_unlang_resume_t callback, diff --git a/src/main/module_unlang.c b/src/main/module_unlang.c index d07b69d1584..937dd836ac8 100644 --- a/src/main/module_unlang.c +++ b/src/main/module_unlang.c @@ -218,31 +218,6 @@ static unlang_action_t module_unlang_resume(REQUEST *request, rlm_rcode_t *presu } } -/** Push a function onto the stack for execution and a resumption function to call after it completes - * - * @param[in] request The current request. - * @param[in] func to call. - * @param[in] resume function to call when the function we pushed is complete. - * @param[in] signal function to call if a signal is received. - * @param[in] rctx to pass to the pushed function and resume()/signal() callbacks. - * @return - * - RLM_MODULE_YIELD. - */ -rlm_rcode_t module_unlang_push_function(REQUEST *request, - unlang_function_t func, unlang_function_t repeat, - fr_module_unlang_resume_t resume, - fr_module_unlang_signal_t signal, void *rctx) -{ - /* - * Push the resumption point - */ - (void) unlang_module_yield(request, resume, signal, rctx); - - unlang_push_function(request, func, repeat, rctx); - - return RLM_MODULE_YIELD; /* This may allow us to do optimisations in future */ -} - /** Push a pre-compiled xlat and resumption state onto the stack for evaluation * * In order to use the async unlang processor the calling module needs to establish diff --git a/src/modules/rlm_eap/rlm_eap.c b/src/modules/rlm_eap/rlm_eap.c index cfd1c0c8895..059a0ad363b 100644 --- a/src/modules/rlm_eap/rlm_eap.c +++ b/src/modules/rlm_eap/rlm_eap.c @@ -343,7 +343,8 @@ static rlm_rcode_t mod_authenticate_result(REQUEST *request, void *instance, UNU eap_fail(eap_session); eap_session_destroy(&eap_session); - return RLM_MODULE_INVALID; + rcode = RLM_MODULE_INVALID; + goto finish; } /* @@ -416,6 +417,8 @@ static rlm_rcode_t mod_authenticate_result(REQUEST *request, void *instance, UNU */ eap_session_freeze(&eap_session); +finish: + talloc_free(rctx); /* Free rctx */ return rcode; } @@ -580,9 +583,14 @@ module_call: rctx->eap_session = eap_session; rctx->rcode = RLM_MODULE_UNKNOWN; - request->module = method->submodule->name; - return module_unlang_push_function(request, eap_call_submodule, eap_call_submodule, - mod_authenticate_result, NULL, rctx); + /* + * mod_authenticate_result will be called after + * eap_call_submodule finishes. + */ + unlang_module_yield(request, mod_authenticate_result, NULL, rctx); + unlang_push_function(request, eap_call_submodule, eap_call_submodule, rctx); + + return RLM_MODULE_YIELD; } static rlm_rcode_t mod_authenticate(void *instance, UNUSED void *thread, REQUEST *request)