1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 02:33:17 +02:00

ext/ldap: Allow default host from ldap.conf to work.

This fixes an regression introduced in
e7af0fe1eb. Previously, calling
ldap_connect() with no parameters would pass NULL to ldap_init(),
which causes it to use the default host specified in
/etc/ldap/ldap.conf (on Ubuntu).

When the code changed to use ldap_initialize(), it initialized a uri,
even if there were no parameters passed to ldap_connect(). Because of
this, there's no way to pass a NULL into ldap_initialize(), making it
impossible to use the default uri from ldap.conf.

This commit bypasses the uri creation when there is no host argument,
passing on a NULL to ldap_initialize() which restores the old PHP 5.5
behavior.
This commit is contained in:
David Caldwell
2017-05-25 00:41:12 +00:00
committed by Côme Bernigaud
parent 65edf44291
commit 747e93eabc
+2 -2
View File
@@ -409,7 +409,7 @@ PHP_FUNCTION(ldap_connect)
{
int rc = LDAP_SUCCESS;
char *url = host;
if (!ldap_is_ldap_url(url)) {
if (url && !ldap_is_ldap_url(url)) {
int urllen = hostlen + sizeof( "ldap://:65535" );
if (port <= 0 || port > 65535) {
@@ -419,7 +419,7 @@ PHP_FUNCTION(ldap_connect)
}
url = emalloc(urllen);
snprintf( url, urllen, "ldap://%s:" ZEND_LONG_FMT, host ? host : "", port );
snprintf( url, urllen, "ldap://%s:" ZEND_LONG_FMT, host, port );
}
#ifdef LDAP_API_FEATURE_X_OPENLDAP