The branch, master has been updated
       via  4c657abaa0a s3:libads: Allocate cli_credentials on a stackframe
      from  8c458675c10 docs-xml:smb.conf: Fix "ctdbd socket" documentation

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4c657abaa0a65cb1922b966a419b1dbb2be274b2
Author: Pavel Filipenský <[email protected]>
Date:   Thu Jan 22 14:27:09 2026 +0100

    s3:libads: Allocate cli_credentials on a stackframe
    
    This fixes:
    ERROR: talloc_free with references at ../../source3/libads/ldap_utils.c:158
    
    What happens:
    
    * `struct cli_credentials *creds` is allocated on `ads` talloc context
    * gensec_set_credentials() creates a talloc_reference to `creds`
    * TALLOC_FREE(creds) sees two parents and complains
    
    All other code is using temporary talloc_stackframe() for `creds`.
    Do it here as well.
    
    Signed-off-by: Pavel Filipenský <[email protected]>
    Reviewed-by: Stefan Metzmacher <[email protected]>
    
    Autobuild-User(master): Stefan Metzmacher <[email protected]>
    Autobuild-Date(master): Fri Jan 23 11:20:28 UTC 2026 on atb-devel-224

-----------------------------------------------------------------------

Summary of changes:
 source3/libads/ldap_utils.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index fd154c6b6e5..26d0063bc13 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -123,6 +123,7 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT 
*ads, const char *bind
                struct cli_credentials *creds = NULL;
                char *cred_name = NULL;
                NTSTATUS ntstatus;
+               TALLOC_CTX *frame = talloc_stackframe();
 
                search_end = time(NULL);
                if (NT_STATUS_EQUAL(ads_ntstatus(status), NT_STATUS_IO_TIMEOUT))
@@ -140,18 +141,20 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT 
*ads, const char *bind
                        DBG_NOTICE("Search for %s in <%s> failed: %s\n",
                                   expr, bp, ads_errstr(status));
                        SAFE_FREE(bp);
+                       TALLOC_FREE(frame);
                        return status;
                }
 
                ntstatus = ads->auth.reconnect_state->fn(ads,
                                ads->auth.reconnect_state->private_data,
-                               ads, &creds);
+                               frame, &creds);
                if (!NT_STATUS_IS_OK(ntstatus)) {
                        DBG_WARNING("Failed to get creds for realm(%s): %s\n",
                                    ads->server.realm, nt_errstr(ntstatus));
                        DBG_WARNING("Search for %s in <%s> failed: %s\n",
                                   expr, bp, ads_errstr(status));
                        SAFE_FREE(bp);
+                       TALLOC_FREE(frame);
                        return status;
                }
 
@@ -172,11 +175,11 @@ static ADS_STATUS ads_do_search_retry_internal(ADS_STRUCT 
*ads, const char *bind
                         * callers depend on it being around.
                         */
                        ads_disconnect(ads);
-                       TALLOC_FREE(creds);
+                       TALLOC_FREE(frame);
                        SAFE_FREE(bp);
                        return status;
                }
-               TALLOC_FREE(creds);
+               TALLOC_FREE(frame);
 
                *res = NULL;
 


-- 
Samba Shared Repository

Reply via email to