After a quick run with the 'weird' charset, squash a few bugs in our new
authorAndrew Bartlett <abartlet@samba.org>
Sat, 26 Apr 2003 13:29:37 +0000 (13:29 +0000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 26 Apr 2003 13:29:37 +0000 (13:29 +0000)
'UF8-safe' LDAP code.

I hope I've caught all the places where we were pushing strings into or
out of LDAP now.

Andrew Bartlett
(This used to be commit 70bf7a5f71f71aeb5338723d1f5b32a89d5c4f91)

source3/passdb/pdb_ldap.c

index 7344835fde88f95d081ed7fd36464bbd1707d4bf..4390e9d5bad796d8a9de9ece7d53bfab3401c836 100644 (file)
@@ -555,7 +555,7 @@ static int ldapsam_search(struct ldapsam_privates *ldap_state,
                        continue;
                
                rc = ldap_search_s(ldap_state->ldap_struct, base, scope, 
-                                  filter, (char **)attrs, attrsonly, res);
+                                  utf8_filter, (char **)attrs, attrsonly, res);
        }
        
        if (rc == LDAP_SERVER_DOWN) {
@@ -584,7 +584,7 @@ static int ldapsam_modify(struct ldapsam_privates *ldap_state, const char *dn, L
                if ((rc = ldapsam_retry_open(ldap_state,&attempts)) != LDAP_SUCCESS)
                        continue;
                
-               rc = ldap_modify_s(ldap_state->ldap_struct, dn, attrs);
+               rc = ldap_modify_s(ldap_state->ldap_struct, utf8_dn, attrs);
        }
        
        if (rc == LDAP_SERVER_DOWN) {
@@ -613,7 +613,7 @@ static int ldapsam_add(struct ldapsam_privates *ldap_state, const char *dn, LDAP
                if ((rc = ldapsam_retry_open(ldap_state,&attempts)) != LDAP_SUCCESS)
                        continue;
                
-               rc = ldap_add_s(ldap_state->ldap_struct, dn, attrs);
+               rc = ldap_add_s(ldap_state->ldap_struct, utf8_dn, attrs);
        }
        
        if (rc == LDAP_SERVER_DOWN) {
@@ -642,7 +642,7 @@ static int ldapsam_delete(struct ldapsam_privates *ldap_state, char *dn)
                if ((rc = ldapsam_retry_open(ldap_state,&attempts)) != LDAP_SUCCESS)
                        continue;
                
-               rc = ldap_delete_s(ldap_state->ldap_struct, dn);
+               rc = ldap_delete_s(ldap_state->ldap_struct, utf8_dn);
        }
        
        if (rc == LDAP_SERVER_DOWN) {
@@ -1919,11 +1919,16 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
                char *retoid;
                struct berval *retdata;
                char *utf8_password;
+               char *utf8_dn;
 
                if (push_utf8_allocate(&utf8_password, pdb_get_plaintext_passwd(newpwd)) == (size_t)-1) {
                        return NT_STATUS_NO_MEMORY;
                }
 
+               if (push_utf8_allocate(&utf8_dn, dn) == (size_t)-1) {
+                       return NT_STATUS_NO_MEMORY;
+               }
+
                if ((ber = ber_alloc_t(LBER_USE_DER))==NULL) {
                        DEBUG(0,("ber_alloc_t returns NULL\n"));
                        SAFE_FREE(utf8_password);
@@ -1931,17 +1936,19 @@ static NTSTATUS ldapsam_modify_entry(struct pdb_methods *my_methods,
                }
 
                ber_printf (ber, "{");
-               ber_printf (ber, "ts", LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID,dn);
+               ber_printf (ber, "ts", LDAP_TAG_EXOP_X_MODIFY_PASSWD_ID, utf8_dn);
                ber_printf (ber, "ts", LDAP_TAG_EXOP_X_MODIFY_PASSWD_NEW, utf8_password);
                ber_printf (ber, "N}");
 
                if ((rc = ber_flatten (ber, &bv))<0) {
                        DEBUG(0,("ber_flatten returns a value <0\n"));
                        ber_free(ber,1);
+                       SAFE_FREE(utf8_dn);
                        SAFE_FREE(utf8_password);
                        return NT_STATUS_UNSUCCESSFUL;
                }
                
+               SAFE_FREE(utf8_dn);
                SAFE_FREE(utf8_password);
                ber_free(ber, 1);