Skip to content

Commit 2fb88b2

Browse files
committed
Fix GH-17704: ldap_search fails when $attributes contains a non-packed array with numerical keys
Closes GH-17710.
1 parent 68d2bc4 commit 2fb88b2

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ PHP NEWS
1212
zend.exception_ignore_args=1 into account). (timwolla)
1313
. Fix fallback paths in fast_long_{add,sub}_function. (nielsdos)
1414

15+
- LDAP:
16+
. Fixed bug GH-17704 (ldap_search fails when $attributes contains a
17+
non-packed array with numerical keys). (nielsdos, 7u83)
18+
1519
- MBString:
1620
. Fixed bug GH-17503 (Undefined float conversion in mb_convert_variables).
1721
(cmb)

ext/ldap/ldap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static bool php_ldap_is_numerically_indexed_array(zend_array *arr)
248248
}
249249
} ZEND_HASH_FOREACH_END();
250250

251-
return false;
251+
return true;
252252
}
253253

254254
/* {{{ Parse controls from and to arrays */

ext/ldap/tests/gh17704.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-17704 (ldap_search fails when $attributes contains a non-packed array with numerical keys)
3+
--EXTENSIONS--
4+
ldap
5+
--SKIPIF--
6+
<?php
7+
require_once('skipifbindfailure.inc');
8+
?>
9+
--FILE--
10+
<?php
11+
include "connect.inc";
12+
13+
$link = ldap_connect_and_bind($uri, $user, $passwd, $protocol_version);
14+
15+
$attributes = ["uid", "cn"];
16+
// force a non-packed array
17+
$attributes["x"] = "x";
18+
unset($attributes["x"]);
19+
20+
var_dump(ldap_search($link, $base, "(o=*)", $attributes));
21+
?>
22+
--EXPECTF--
23+
object(LDAP\Result)#%d (0) {
24+
}

0 commit comments

Comments
 (0)