ext/ldap: Check that array key is not empty

This commit is contained in:
Gina Peter Banyard 2024-10-01 00:28:25 +01:00
parent 72ee812e2a
commit 0733e90c7f
2 changed files with 6 additions and 3 deletions

View file

@ -2239,6 +2239,11 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
RETVAL_FALSE;
goto cleanup;
}
if (ZSTR_LEN(attribute) == 0) {
zend_argument_value_error(3, "key must not be empty");
RETVAL_FALSE;
goto cleanup;
}
if (zend_str_has_nul_byte(attribute)) {
zend_argument_value_error(3, "key must not contain any null bytes");
RETVAL_FALSE;

View file

@ -134,9 +134,7 @@ try {
--EXPECTF--
ValueError: ldap_add(): Argument #3 ($entry) must not be empty
ValueError: ldap_add(): Argument #3 ($entry) must be an associative array of attribute => values
Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d
bool(false)
ValueError: ldap_add(): Argument #3 ($entry) key must not be empty
ValueError: ldap_add(): Argument #3 ($entry) key must not contain any null bytes
Error: Object of class stdClass could not be converted to string
ValueError: ldap_add(): Argument #3 ($entry) list of attribute values must not be empty