tony2001 Wed Apr 16 13:17:44 2008 UTC Modified files: /php-src/ext/ldap ldap.c Log: unicode support and minor leak fix http://cvs.php.net/viewvc.cgi/php-src/ext/ldap/ldap.c?r1=1.181&r2=1.182&diff_format=u Index: php-src/ext/ldap/ldap.c diff -u php-src/ext/ldap/ldap.c:1.181 php-src/ext/ldap/ldap.c:1.182 --- php-src/ext/ldap/ldap.c:1.181 Wed Apr 16 13:02:26 2008 +++ php-src/ext/ldap/ldap.c Wed Apr 16 13:17:44 2008 @@ -23,7 +23,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: ldap.c,v 1.181 2008/04/16 13:02:26 tony2001 Exp $ */ +/* $Id: ldap.c,v 1.182 2008/04/16 13:17:44 tony2001 Exp $ */ #define IS_EXT_MODULE #ifdef HAVE_CONFIG_H @@ -237,7 +237,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "LDAP Support", "enabled"); - php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.181 2008/04/16 13:02:26 tony2001 Exp $"); + php_info_print_table_row(2, "RCS Version", "$Id: ldap.c,v 1.182 2008/04/16 13:17:44 tony2001 Exp $"); if (LDAPG(max_links) == -1) { snprintf(tmp, 31, "%ld/unlimited", LDAPG(num_links)); @@ -1294,9 +1294,10 @@ ldap_linkdata *ld; char *dn; LDAPMod **ldap_mods; - int i, j, num_attribs, num_values, dn_len; + int i, j, num_attribs, num_values, dn_len, res; + unsigned int attribute_len; int *num_berval; - char *attribute; + zstr attribute; ulong index; int is_full_add=0; /* flag for full add operation so ldap_mod_add can be put back into oper, gerrit THomson */ @@ -1322,13 +1323,27 @@ ldap_mods[i] = emalloc(sizeof(LDAPMod)); ldap_mods[i]->mod_op = oper | LDAP_MOD_BVALUES; - if (zend_hash_get_current_key(Z_ARRVAL_P(entry), &attribute, &index, 0) == HASH_KEY_IS_STRING) { - ldap_mods[i]->mod_type = estrdup(attribute); + res = zend_hash_get_current_key_ex(Z_ARRVAL_P(entry), &attribute, &attribute_len, &index, 0, NULL); + if (res == HASH_KEY_IS_STRING) { + ldap_mods[i]->mod_type = estrndup(attribute.s, attribute_len - 1); + } else if (res == HASH_KEY_IS_UNICODE) { + char *tmp = zend_unicode_to_ascii(attribute.u, attribute_len - 1 TSRMLS_CC); + if (tmp) { + ldap_mods[i]->mod_type = estrdup(tmp); + } else { + ldap_mods[i]->mod_type = NULL; + goto error_out; + } } else { +error_out: php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unknown attribute in the data"); /* Free allocated memory */ while (i >= 0) { - efree(ldap_mods[i--]); + if (ldap_mods[i]->mod_type) { + efree(ldap_mods[i]->mod_type); + } + efree(ldap_mods[i]); + i--; } efree(num_berval); efree(ldap_mods);
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php