From: Nick Porter Date: Thu, 7 Sep 2023 13:25:22 +0000 (+0100) Subject: Ensure auth bind resume functions clear up after failed requests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=64f51a1de826a4e059a518257be449fa9c36cfa8;p=thirdparty%2Ffreeradius-server.git Ensure auth bind resume functions clear up after failed requests --- diff --git a/src/lib/ldap/bind.c b/src/lib/ldap/bind.c index 90456507fa4..2e9b8e94018 100644 --- a/src/lib/ldap/bind.c +++ b/src/lib/ldap/bind.c @@ -279,10 +279,17 @@ static unlang_action_t ldap_async_auth_bind_results(rlm_rcode_t *p_result, UNUSE break; } - /* - * Bind auth ctx is freed by trunk request free. - */ - fr_trunk_request_signal_complete(bind_auth_ctx->treq); + if (bind_auth_ctx->treq) { + /* + * Bind auth ctx is freed by trunk request free. + */ + fr_trunk_request_signal_complete(bind_auth_ctx->treq); + } else { + /* + * If there is no trunk request, the request failed, and we need to free the ctx + */ + talloc_free(bind_auth_ctx); + } RETURN_MODULE_RCODE(rcode); } diff --git a/src/lib/ldap/sasl.c b/src/lib/ldap/sasl.c index 8faa355ca9f..6a848cfcaa2 100644 --- a/src/lib/ldap/sasl.c +++ b/src/lib/ldap/sasl.c @@ -449,13 +449,19 @@ static unlang_action_t ldap_async_sasl_bind_auth_results(rlm_rcode_t *p_result, break; } - if (bind_auth_ctx->treq->tconn) ldap_conn = talloc_get_type_abort(bind_auth_ctx->treq->tconn->conn->h, - fr_ldap_connection_t); - - /* - * Will free bind_auth_ctx - */ - fr_trunk_request_signal_complete(bind_auth_ctx->treq); + if (bind_auth_ctx->treq) { + if (bind_auth_ctx->treq->tconn) ldap_conn = talloc_get_type_abort(bind_auth_ctx->treq->tconn->conn->h, + fr_ldap_connection_t); + /* + * Will free bind_auth_ctx + */ + fr_trunk_request_signal_complete(bind_auth_ctx->treq); + } else { + /* + * If there is no trunk request, the request failed, and we need to free the ctx + */ + talloc_free(bind_auth_ctx); + } switch (ret) { case LDAP_PROC_SUCCESS: