Skip to content

Gh18902 #18903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Gh18902 #18903

Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4036,7 +4036,12 @@ static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) {
LDAPControl **lserverctrls = NULL;
int rc, msgid;

if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
RETURN_THROWS();
}

if (ZSTR_LEN(reqoid) == 0) {
zend_argument_value_error(2, "cannot be empty");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And use the zend_argument_must_not_be_empty_error helper when merging up

Suggested change
zend_argument_value_error(2, "cannot be empty");
zend_argument_value_error(2, "must not be empty");

RETURN_THROWS();
}

Expand Down
38 changes: 38 additions & 0 deletions ext/ldap/tests/gh18902.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
--TEST--
GH-17704 (ldap_search fails when $attributes contains a non-packed array with numerical keys)
--EXTENSIONS--
ldap
--FILE--
<?php
$conn = ldap_connect();
try {
ldap_exop($conn,null);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this case, as it is covered by the empty string one, and this reduces future churn when passing null becomes a TypeError.


try {
ldap_exop($conn,"\0");
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}

try {
ldap_exop_sync($conn,"");
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}

try {
ldap_exop_sync($conn,"test\0");
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--

Deprecated: ldap_exop(): Passing null to parameter #2 ($request_oid) of type string is deprecated in %s on line %d
ldap_exop(): Argument #2 ($request_oid) cannot be empty
ldap_exop(): Argument #2 ($request_oid) must not contain any null bytes
ldap_exop_sync(): Argument #2 ($request_oid) cannot be empty
ldap_exop_sync(): Argument #2 ($request_oid) must not contain any null bytes
Loading