Author: idra
Date: 2007-09-10 19:14:22 +0000 (Mon, 10 Sep 2007)
New Revision: 25063

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25063

Log:

Fix segfault in smbldp_set_creds when we want to use anonymous, the
code was not passing in the "anon" flag correctly and was passing
NULL pointers.



Modified:
   branches/SAMBA_3_0_25/source/nsswitch/idmap_ldap.c
   branches/SAMBA_3_2/source/nsswitch/idmap_ldap.c
   branches/SAMBA_3_2_0/source/nsswitch/idmap_ldap.c


Changeset:
Modified: branches/SAMBA_3_0_25/source/nsswitch/idmap_ldap.c
===================================================================
--- branches/SAMBA_3_0_25/source/nsswitch/idmap_ldap.c  2007-09-10 19:04:57 UTC 
(rev 25062)
+++ branches/SAMBA_3_0_25/source/nsswitch/idmap_ldap.c  2007-09-10 19:14:22 UTC 
(rev 25063)
@@ -78,6 +78,7 @@
        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 @@
                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 @@
                }
        }
 
-       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;

Modified: branches/SAMBA_3_2/source/nsswitch/idmap_ldap.c
===================================================================
--- branches/SAMBA_3_2/source/nsswitch/idmap_ldap.c     2007-09-10 19:04:57 UTC 
(rev 25062)
+++ branches/SAMBA_3_2/source/nsswitch/idmap_ldap.c     2007-09-10 19:14:22 UTC 
(rev 25063)
@@ -78,6 +78,7 @@
        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 @@
                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 @@
                }
        }
 
-       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;

Modified: branches/SAMBA_3_2_0/source/nsswitch/idmap_ldap.c
===================================================================
--- branches/SAMBA_3_2_0/source/nsswitch/idmap_ldap.c   2007-09-10 19:04:57 UTC 
(rev 25062)
+++ branches/SAMBA_3_2_0/source/nsswitch/idmap_ldap.c   2007-09-10 19:14:22 UTC 
(rev 25063)
@@ -78,6 +78,7 @@
        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 @@
                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 @@
                }
        }
 
-       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;

Reply via email to