Skip to content

Commit d51b8f9

Browse files
committed
ext/ldap: Allow default host from ldap.conf to work.
This fixes an regression introduced in e7af0fe. 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.
1 parent 872e43d commit d51b8f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ext/ldap/ldap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ PHP_FUNCTION(ldap_connect)
366366
{
367367
int rc = LDAP_SUCCESS;
368368
char *url = host;
369-
if (!ldap_is_ldap_url(url)) {
369+
if (url && !ldap_is_ldap_url(url)) {
370370
int urllen = hostlen + sizeof( "ldap://:65535" );
371371

372372
if (port <= 0 || port > 65535) {
@@ -376,7 +376,7 @@ PHP_FUNCTION(ldap_connect)
376376
}
377377

378378
url = emalloc(urllen);
379-
snprintf( url, urllen, "ldap://%s:%ld", host ? host : "", port );
379+
snprintf( url, urllen, "ldap://%s:%ld", host, port );
380380
}
381381

382382
#ifdef LDAP_API_FEATURE_X_OPENLDAP

0 commit comments

Comments
 (0)