Skip to content

Commit 6499b56

Browse files
committed
Fix GH-21262: ldap_modify() too strict controls argument validation.
make it impossible to unset an attribute.
1 parent 1b5c5e0 commit 6499b56

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ext/ldap/ldap.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,9 +2339,14 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, bool ext)
23392339
SEPARATE_ARRAY(attribute_values);
23402340
uint32_t num_values = zend_hash_num_elements(Z_ARRVAL_P(attribute_values));
23412341
if (num_values == 0) {
2342-
zend_argument_value_error(3, "attribute \"%s\" must be a non-empty list of attribute values", ZSTR_VAL(attribute));
2343-
RETVAL_FALSE;
2344-
goto cleanup;
2342+
if (UNEXPECTED(is_full_add)) {
2343+
zend_argument_value_error(3, "attribute \"%s\" must be a non-empty list of attribute values", ZSTR_VAL(attribute));
2344+
RETVAL_FALSE;
2345+
goto cleanup;
2346+
}
2347+
/* When we modify, we means we delete the attribute */
2348+
attribute_index ++;
2349+
continue;
23452350
}
23462351
if (!php_ldap_is_numerically_indexed_array(Z_ARRVAL_P(attribute_values))) {
23472352
zend_argument_value_error(3, "attribute \"%s\" must be an array of attribute values with numeric keys", ZSTR_VAL(attribute));

0 commit comments

Comments
 (0)