Skip to content

Commit 72ee812

Browse files
committed
ext/ldap: Check array key does not have any nul bytes
1 parent d34d015 commit 72ee812

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 (zend_str_has_nul_byte(attribute)) {
2243+
zend_argument_value_error(3, "key must not contain any null bytes");
2244+
RETVAL_FALSE;
2245+
goto cleanup;
2246+
}
22422247

22432248
ldap_mods[attribute_index] = emalloc(sizeof(LDAPMod));
22442249
ldap_mods[attribute_index]->mod_op = oper | LDAP_MOD_BVALUES;

ext/ldap/tests/ldap_add_modify_delete_programming_errors.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ ValueError: ldap_add(): Argument #3 ($entry) must be an associative array of att
137137

138138
Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d
139139
bool(false)
140-
141-
Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d
142-
bool(false)
140+
ValueError: ldap_add(): Argument #3 ($entry) key must not contain any null bytes
143141
Error: Object of class stdClass could not be converted to string
144142
ValueError: ldap_add(): Argument #3 ($entry) list of attribute values must not be empty
145143
ValueError: ldap_add(): Argument #3 ($entry) must be a list of attribute values

0 commit comments

Comments
 (0)