]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add a talloc reference from trunk request to LDAP query. Fixes #4598
authorNick Porter <nick@portercomputing.co.uk>
Mon, 24 Apr 2023 17:38:34 +0000 (18:38 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 1 May 2023 10:37:12 +0000 (11:37 +0100)
Ensures the LDAP query will last until the trunk request is freed.

Specifically, in the case that the packet processing times out and the
trunk request is singlalled to be cancelled, the query needs to live
until the cancel_mux function is called.

src/lib/ldap/base.c
src/lib/ldap/referral.c

index 37beb0b4d43fb11ada3de0475e19b8176d9f63fd..01b3f4d5c7ec71646704089b3736cd6fe74fbbe5 100644 (file)
@@ -699,6 +699,10 @@ unlang_action_t fr_ldap_trunk_search(rlm_rcode_t *p_result,
        switch (fr_trunk_request_enqueue(&query->treq, ttrunk->trunk, request, query, NULL)) {
        case FR_TRUNK_ENQUEUE_OK:
        case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+               /*
+                *      Ensure the query ctx will last until the trunk request frees its children
+                */
+               talloc_reference(query->treq, query);
                break;
 
        default:
@@ -773,6 +777,10 @@ unlang_action_t fr_ldap_trunk_modify(rlm_rcode_t *p_result,
        switch (fr_trunk_request_enqueue(&query->treq, ttrunk->trunk, request, query, NULL)) {
        case FR_TRUNK_ENQUEUE_OK:
        case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+               /*
+                *      Ensure the query ctx will last until the trunk request frees its children
+                */
+               talloc_reference(query->treq, query);
                break;
 
        default:
@@ -866,6 +874,10 @@ unlang_action_t fr_ldap_trunk_extended(rlm_rcode_t *p_result,
        switch (fr_trunk_request_enqueue(&query->treq, ttrunk->trunk, request, query, NULL)) {
        case FR_TRUNK_ENQUEUE_OK:
        case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+               /*
+                *      Ensure the query ctx will last until the trunk request frees its children
+                */
+               talloc_reference(query->treq, query);
                break;
 
        default:
index 47e90d4f76f08a947cb8817f6bf3535f64f3d82a..a5d56a988999d5fe77441955bde79eba610495b3 100644 (file)
@@ -82,6 +82,7 @@ static void _ldap_referral_send(UNUSED fr_trunk_t *trunk, UNUSED fr_trunk_state_
        switch (fr_trunk_request_enqueue(&query->treq, referral->ttrunk->trunk, request, query, NULL)) {
        case FR_TRUNK_ENQUEUE_OK:
        case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+               talloc_reference(query->treq, query);
                break;
 
        default:
@@ -237,6 +238,7 @@ int fr_ldap_referral_follow(fr_ldap_thread_t *t, request_t *request, fr_ldap_que
                switch (fr_trunk_request_enqueue(&query->treq, ttrunk->trunk, request, query, NULL)) {
                case FR_TRUNK_ENQUEUE_OK:
                case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+                       talloc_reference(query->treq, query);
                        break;
 
                default:
@@ -328,6 +330,7 @@ int fr_ldap_referral_next(fr_ldap_thread_t *t, request_t *request, fr_ldap_query
                switch(fr_trunk_request_enqueue(&query->treq, ttrunk->trunk, request, query, NULL)) {
                case FR_TRUNK_ENQUEUE_OK:
                case FR_TRUNK_ENQUEUE_IN_BACKLOG:
+                       talloc_reference(query->treq, query);
                        break;
 
                default: