Fix crash in LDAP search functions during argument validation

This commit is contained in:
Máté Kocsis 2021-03-15 23:07:05 +01:00
parent 5ecc078a17
commit b03438ba3a
No known key found for this signature in database
GPG key ID: FD055E41728BF310
2 changed files with 18 additions and 0 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

@ -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