diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-02-20 22:25:42 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-02-20 22:25:42 +0300 |
commit | 71d41ca6bb3a9d888b39f34a30f994ac1cf88873 (patch) | |
tree | 3a11365b77b332c078440204fb82549d34237a35 /ext/ldap/ldap.c | |
parent | 2d50280dd013556e51b6f275ca965fe7b530029b (diff) | |
parent | 1ceec3a053647865493ab417d3ce401b9bc42450 (diff) | |
download | php-71d41ca6bb3a9d888b39f34a30f994ac1cf88873.tar.gz |
Merge branch 'master-5.6' of git://anonscm.debian.org/pkg-php/php
Conflicts:
debian/changelog
debian/patches/series
Diffstat (limited to 'ext/ldap/ldap.c')
-rw-r--r-- | ext/ldap/ldap.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 50055a25a..f9e41ff79 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2014 The PHP Group | + | Copyright (c) 1997-2015 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -391,6 +391,23 @@ static int _get_lderrno(LDAP *ldap) } /* }}} */ +/* {{{ _set_lderrno + */ +static void _set_lderrno(LDAP *ldap, int lderr) +{ +#if !HAVE_NSLDAP +#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP + /* New versions of OpenLDAP do it this way */ + ldap_set_option(ldap, LDAP_OPT_ERROR_NUMBER, &lderr); +#else + ldap->ld_errno = lderr; +#endif +#else + ldap_set_lderrno(ldap, lderr, NULL, NULL); +#endif +} +/* }}} */ + /* {{{ proto bool ldap_bind(resource link [, string dn [, string password]]) Bind to LDAP directory */ PHP_FUNCTION(ldap_bind) @@ -405,18 +422,20 @@ PHP_FUNCTION(ldap_bind) RETURN_FALSE; } + ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link); + if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) { + _set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS); php_error_docref(NULL TSRMLS_CC, E_WARNING, "DN contains a null byte"); RETURN_FALSE; } if (ldap_bind_pw != NULL && memchr(ldap_bind_pw, '\0', ldap_bind_pwlen) != NULL) { + _set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS); php_error_docref(NULL TSRMLS_CC, E_WARNING, "Password contains a null byte"); RETURN_FALSE; } - ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link); - if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc)); RETURN_FALSE; |