Skip to content

Commit 16b272d

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: ext/ldap: Fix GH-16101 (Segfaults in php_ldap_do_search() when LDAPs is not a list)
2 parents e051215 + 0f2fe67 commit 16b272d

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ PHP NEWS
3030
- LDAP:
3131
. Fixed bug GH-16032 (Various NULL pointer dereferencements in
3232
ldap_modify_batch()). (Girgias)
33+
. Fixed bug GH-16101 (Segfault in ldap_list(), ldap_read(), and ldap_search()
34+
when LDAPs array is not a list). (Girgias)
3335

3436
- Opcache:
3537
. Fixed bug GH-16009 (Segmentation fault with frameless functions and

ext/ldap/ldap.c

+5
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,11 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
15051505
ret = 0;
15061506
goto cleanup;
15071507
}
1508+
if (!zend_array_is_list(Z_ARRVAL_P(link))) {
1509+
zend_argument_value_error(1, "must be a list");
1510+
ret = 0;
1511+
goto cleanup;
1512+
}
15081513

15091514
if (base_dn_ht) {
15101515
nbases = zend_hash_num_elements(base_dn_ht);

ext/ldap/tests/gh16101.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
Bug GH-16101: Segfault in ldap_list(), ldap_read(), and ldap_search() when LDAPs array is not a list
3+
--EXTENSIONS--
4+
ldap
5+
--FILE--
6+
<?php
7+
8+
/* We are assuming 3333 is not connectable */
9+
$ldap = ldap_connect('ldap://127.0.0.1:3333');
10+
$valid_dn = "cn=userA,something";
11+
$valid_filter = "";
12+
13+
$ldaps_dict = [
14+
"hello" => $ldap,
15+
"world" => $ldap,
16+
];
17+
try {
18+
var_dump(ldap_list($ldaps_dict, $valid_dn, $valid_filter));
19+
} catch (Throwable $e) {
20+
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
21+
}
22+
23+
?>
24+
--EXPECT--
25+
ValueError: ldap_list(): Argument #1 ($ldap) must be a list

0 commit comments

Comments
 (0)