Skip to content

Commit 0733e90

Browse files
committed
ext/ldap: Check that array key is not empty
1 parent 72ee812 commit 0733e90

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ext/ldap/ldap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,6 +2239,11 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
22392239
RETVAL_FALSE;
22402240
goto cleanup;
22412241
}
2242+
if (ZSTR_LEN(attribute) == 0) {
2243+
zend_argument_value_error(3, "key must not be empty");
2244+
RETVAL_FALSE;
2245+
goto cleanup;
2246+
}
22422247
if (zend_str_has_nul_byte(attribute)) {
22432248
zend_argument_value_error(3, "key must not contain any null bytes");
22442249
RETVAL_FALSE;

ext/ldap/tests/ldap_add_modify_delete_programming_errors.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ try {
134134
--EXPECTF--
135135
ValueError: ldap_add(): Argument #3 ($entry) must not be empty
136136
ValueError: ldap_add(): Argument #3 ($entry) must be an associative array of attribute => values
137-
138-
Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d
139-
bool(false)
137+
ValueError: ldap_add(): Argument #3 ($entry) key must not be empty
140138
ValueError: ldap_add(): Argument #3 ($entry) key must not contain any null bytes
141139
Error: Object of class stdClass could not be converted to string
142140
ValueError: ldap_add(): Argument #3 ($entry) list of attribute values must not be empty

0 commit comments

Comments
 (0)