Skip to content

Commit ad1b9ee

Browse files
committed
Fix null byte in LDAP bindings
1 parent 40a9316 commit ad1b9ee

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ PHP NEWS
3737
. Fixed bug #66021 (Blank line inside empty array/object when
3838
JSON_PRETTY_PRINT is set). (Kevin Israel)
3939

40+
- LDAP:
41+
. Fixed issue with null bytes in LDAP bindings. (Matthew Daley)
42+
4043
- SimpleXML:
4144
. Fixed bug #66084 (simplexml_load_string() mangles empty node name)
4245
(Anatol)

ext/ldap/ldap.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,16 @@ PHP_FUNCTION(ldap_bind)
399399
RETURN_FALSE;
400400
}
401401

402+
if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) {
403+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "DN contains a null byte");
404+
RETURN_FALSE;
405+
}
406+
407+
if (ldap_bind_pw != NULL && memchr(ldap_bind_pw, '\0', ldap_bind_pwlen) != NULL) {
408+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Password contains a null byte");
409+
RETURN_FALSE;
410+
}
411+
402412
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
403413

404414
if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) {

0 commit comments

Comments
 (0)