Merge branch 'PHP-8.0'

* Fix crash in LDAP search functions during argument validation
* Fix ldap_next_entry() parameter name
This commit is contained in:
Máté Kocsis 2021-03-16 09:34:04 +01:00
commit 66f16f4eb2
No known key found for this signature in database
GPG Key ID: FD055E41728BF310
4 changed files with 25 additions and 4 deletions

View File

@ -1602,11 +1602,15 @@ cleanup_parallel:
if (!base_dn_str) {
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is a resource");
ret = 0;
goto cleanup;
}
ldap_base_dn = zend_string_copy(base_dn_str);
if (!filter_str) {
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is a resource");
ret = 0;
goto cleanup;
}
ldap_filter = zend_string_copy(filter_str);

View File

@ -70,10 +70,10 @@ function ldap_first_entry($ldap, $result) {}
/**
* @param resource $ldap
* @param resource $result
* @param resource $entry
* @return resource|false
*/
function ldap_next_entry($ldap, $result) {}
function ldap_next_entry($ldap, $entry) {}
/**
* @param resource $ldap

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 056fa51afdd7d40f9866ebd67837f5ddfa2c6236 */
* Stub hash: 5cae0fbe180164126aa99ad5465822d87fe73fb9 */
#if defined(HAVE_ORALDAP)
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
@ -78,7 +78,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_entry, 0, 0, 2)
ZEND_ARG_INFO(0, result)
ZEND_END_ARG_INFO()
#define arginfo_ldap_next_entry arginfo_ldap_first_entry
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_entry, 0, 0, 2)
ZEND_ARG_INFO(0, ldap)
ZEND_ARG_INFO(0, entry)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_get_entries, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
ZEND_ARG_INFO(0, ldap)

View File

@ -39,6 +39,18 @@ try {
echo $exception->getMessage() . "\n";
}
try {
ldap_search($link, [], []);
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
}
try {
ldap_search($link, "", []);
} catch (TypeError $exception) {
echo $exception->getMessage() . "\n";
}
?>
--EXPECTF--
Warning: ldap_search(): Search: No such object in %s on line %d
@ -49,3 +61,5 @@ bool(false)
ldap_search(): Argument #1 ($ldap) cannot be empty
ldap_search(): Argument #2 ($base) must have the same number of elements as the links array
ldap_search(): Argument #3 ($filter) must have the same number of elements as the links array
ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is a resource
ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is a resource