Skip to content

Commit 08bf506

Browse files
committed
ext/ldap: php_ldap_do_modify() throw ValueError when entries array is empty
1 parent 3a2a86b commit 08bf506

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ext/ldap/ldap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2216,6 +2216,11 @@ static void php_ldap_do_modify(INTERNAL_FUNCTION_PARAMETERS, int oper, int ext)
22162216
VERIFY_LDAP_LINK_CONNECTED(ld);
22172217

22182218
num_attribs = zend_hash_num_elements(Z_ARRVAL_P(entry));
2219+
if (num_attribs == 0) {
2220+
zend_argument_must_not_be_empty_error(3);
2221+
RETURN_THROWS();
2222+
}
2223+
22192224
ldap_mods = safe_emalloc((num_attribs+1), sizeof(LDAPMod *), 0);
22202225
num_berval = safe_emalloc(num_attribs, sizeof(int), 0);
22212226
zend_hash_internal_pointer_reset(Z_ARRVAL_P(entry));

ext/ldap/tests/ldap_add_modify_delete_programming_errors.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ try {
132132

133133
?>
134134
--EXPECTF--
135-
Warning: ldap_add(): Add: Can't contact LDAP server in %s on line %d
136-
bool(false)
135+
ValueError: ldap_add(): Argument #3 ($entry) must not be empty
137136

138137
Warning: ldap_add(): Unknown attribute in the data in %s on line %d
139138
bool(false)

0 commit comments

Comments
 (0)