]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Ensure auth bind resume functions clear up after failed requests
authorNick Porter <nick@portercomputing.co.uk>
Thu, 7 Sep 2023 13:25:22 +0000 (14:25 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Fri, 8 Sep 2023 07:01:43 +0000 (08:01 +0100)
src/lib/ldap/bind.c
src/lib/ldap/sasl.c

index 90456507fa479ac05748f02f12b905b4d66ec011..2e9b8e9401890025892857807abf6d50dd9688ed 100644 (file)
@@ -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);
 }
index 8faa355ca9f3fc691d3073eadeee3baf5270264a..6a848cfcaa2f31a67934c71c03a65e3b2a226e70 100644 (file)
@@ -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: