Skip to content

Fix GH-17704: ldap_search fails when $attributes contains a non-packed array with numerical keys #17710

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
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
2 changes: 1 addition & 1 deletion ext/ldap/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ static bool php_ldap_is_numerically_indexed_array(zend_array *arr)
}
} ZEND_HASH_FOREACH_END();

return false;
return true;
Copy link
Member

Choose a reason for hiding this comment

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

ah that s unfortunate !

Copy link
Member Author

Choose a reason for hiding this comment

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

I bet this happened during the downwards merge. This was fixed first in master, and then needed a slightly different patch on 8.3-8.4. It's right on master but wrong on 8.3-8.4, so something must've gone wrong while merging

}

/* {{{ Parse controls from and to arrays */
Expand Down
24 changes: 24 additions & 0 deletions ext/ldap/tests/gh17704.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
GH-17704 (ldap_search fails when $attributes contains a non-packed array with numerical keys)
--EXTENSIONS--
ldap
--SKIPIF--
<?php
require_once('skipifbindfailure.inc');
?>
--FILE--
<?php
include "connect.inc";

$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);

$attributes = ["uid", "cn"];
// force a non-packed array
$attributes["x"] = "x";
unset($attributes["x"]);

var_dump(ldap_search($link, $base, "(o=*)", $attributes));
?>
--EXPECTF--
object(LDAP\Result)#%d (0) {
}
Loading