r25063: Fix segfault in smbldp_set_creds when we want to use anonymous, the
authorSimo Sorce <idra@samba.org>
Mon, 10 Sep 2007 19:14:22 +0000 (19:14 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:30:38 +0000 (12:30 -0500)
code was not passing in the "anon" flag correctly and was passing
NULL pointers.

source/nsswitch/idmap_ldap.c

index 7f0747068bc48372c41a5b4bb016620f8c21c445..3e6e65727e30e9891490c4fb1d84cb12a0231a08 100644 (file)
@@ -78,6 +78,7 @@ static NTSTATUS get_credentials( TALLOC_CTX *mem_ctx,
        char *secret = NULL;
        const char *tmp = NULL;
        char *user_dn = NULL;
+       bool anon = false;
 
        /* assume anonymous if we don't have a specified user */
 
@@ -106,7 +107,7 @@ static NTSTATUS get_credentials( TALLOC_CTX *mem_ctx,
                if (!fetch_ldap_pw(&user_dn, &secret)) {
                        DEBUG(2, ("get_credentials: Failed to lookup ldap "
                                  "bind creds. Using anonymous connection.\n"));
-                       *dn = talloc_strdup(mem_ctx, "");
+                       anon = true;
                } else {
                        *dn = talloc_strdup(mem_ctx, user_dn);
                        SAFE_FREE( user_dn );
@@ -114,10 +115,10 @@ static NTSTATUS get_credentials( TALLOC_CTX *mem_ctx,
                }
        }
 
-       smbldap_set_creds(ldap_state, false, *dn, secret);
+       smbldap_set_creds(ldap_state, anon, *dn, secret);
        ret = NT_STATUS_OK;
 
- done:
+done:
        SAFE_FREE(secret);
 
        return ret;