Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2694,7 +2694,7 @@ PHP_FUNCTION(ldap_modify_batch)

ZVAL_DEREF(modtype_zv);
if (UNEXPECTED(Z_TYPE_P(modtype_zv) != IS_LONG)) {
zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be of type int, %s given", zend_zval_value_name(attrib));
zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be of type int, %s given", zend_zval_value_name(modtype_zv));
RETURN_THROWS();
}
zend_long modtype = Z_LVAL_P(modtype_zv);
Expand Down Expand Up @@ -2730,7 +2730,7 @@ PHP_FUNCTION(ldap_modify_batch)

ZVAL_DEREF(modification_values_zv);
if (Z_TYPE_P(modification_values_zv) != IS_ARRAY) {
zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be of type array, %s given", zend_zval_value_name(attrib));
zend_argument_type_error(3, "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be of type array, %s given", zend_zval_value_name(modification_values_zv));
RETURN_THROWS();
}

Expand Down
2 changes: 1 addition & 1 deletion ext/ldap/tests/ldap_modify_batch_programming_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modificatio
ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modification entry must only contain the keys "attrib", "modtype", and "values"
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "attrib" must be of type string, int given
ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "attrib" must not contain null bytes
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, string given
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, stdClass given
ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be LDAP_MODIFY_BATCH_ADD, LDAP_MODIFY_BATCH_REMOVE, LDAP_MODIFY_BATCH_REPLACE, or LDAP_MODIFY_BATCH_REMOVE_ALL
ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modification entry must not contain the "values" option when option "modtype" is LDAP_MODIFY_BATCH_REMOVE_ALL
ValueError: ldap_modify_batch(): Argument #3 ($modifications_info) a modification entry must contain the "values" option when the "modtype" option is not LDAP_MODIFY_BATCH_REMOVE_ALL
Expand Down
25 changes: 25 additions & 0 deletions ext/ldap/tests/ldap_modify_batch_type_error_value.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
ldap_modify_batch(): the type errors name the type of the rejected value
--EXTENSIONS--
ldap
--FILE--
<?php
$l = ldap_connect('ldap://127.0.0.1:1');
foreach ([
[["attrib" => "a", "modtype" => [], "values" => ["v"]]],
[["attrib" => "a", "modtype" => 1.5, "values" => ["v"]]],
[["attrib" => "a", "modtype" => LDAP_MODIFY_BATCH_ADD, "values" => "v"]],
[["attrib" => "a", "modtype" => LDAP_MODIFY_BATCH_ADD, "values" => 5]],
] as $mods) {
try {
ldap_modify_batch($l, "cn=x", $mods);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
?>
--EXPECT--
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, array given
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "modtype" must be of type int, float given
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "values" must be of type array, null given
TypeError: ldap_modify_batch(): Argument #3 ($modifications_info) the value for option "values" must be of type array, int given
Loading