diff options
author | Stig Venaas <venaas@php.net> | 2001-11-13 18:05:47 +0000 |
---|---|---|
committer | Stig Venaas <venaas@php.net> | 2001-11-13 18:05:47 +0000 |
commit | 80ccb3f7f795ffc2144452d7adc1f5ff87bf3e9d (patch) | |
tree | 3969129463274f5abc2dd3a0e7b77c209080192b /ext | |
parent | ca476ecaa47cf6017354c8ddb4ca464f1fb3533b (diff) | |
download | php-git-80ccb3f7f795ffc2144452d7adc1f5ff87bf3e9d.tar.gz |
Minor changes in ldap_connect(): fixed crash with OpenLDAP 2 libs when
called without args and also use ldap_init() rather than ldap_open();
simplified code a little
Diffstat (limited to 'ext')
-rw-r--r-- | ext/ldap/ldap.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index e03612a118..2237a760e1 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -295,8 +295,8 @@ PHP_MINFO_FUNCTION(ldap) Connect to an LDAP server */ PHP_FUNCTION(ldap_connect) { - char *host; - int port; + char *host = NULL; + int port = 389; /* Default port */ #ifdef HAVE_ORALDAP char *wallet, *walletpasswd; int authmode; @@ -306,8 +306,6 @@ PHP_FUNCTION(ldap_connect) switch(ZEND_NUM_ARGS()) { case 0: - host = NULL; - port = 0; break; case 1: { @@ -319,7 +317,6 @@ PHP_FUNCTION(ldap_connect) convert_to_string_ex(yyhost); host = Z_STRVAL_PP(yyhost); - port = 389; /* Default port */ } break; @@ -339,7 +336,7 @@ PHP_FUNCTION(ldap_connect) #ifdef HAVE_ORALDAP case 5: { - pval **yyhost, **yyport, **yywallet, **yywalletpasswd, **yyauthmode; + pval **yyhost, **yyport, **yywallet, **yywalletpasswd, **yyauthmode; if (zend_get_parameters_ex(5, &yyhost, &yyport, &yywallet, &yywalletpasswd, &yyauthmode) == FAILURE) { RETURN_FALSE; @@ -371,7 +368,7 @@ PHP_FUNCTION(ldap_connect) } #ifdef LDAP_API_FEATURE_X_OPENLDAP - if (strchr(host, '/')) { + if (host != NULL && strchr(host, '/')) { int rc; rc = ldap_initialize(&ldap, host); @@ -379,11 +376,12 @@ PHP_FUNCTION(ldap_connect) php_error(E_WARNING, "Could not create LDAP session handle (%d): %s\n", rc, ldap_err2string(rc)); RETURN_FALSE; } - } else -#endif - { - ldap = ldap_open(host, port); + } else { + ldap = ldap_init(host, port); } +#else + ldap = ldap_open(host, port); +#endif if ( ldap == NULL ) { RETURN_FALSE; |