Skip to content

Commit 0f2fe67

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: ext/ldap: Fix GH-16101 (Segfaults in php_ldap_do_search() when LDAPs is not a list)
2 parents 37a73a8 + 19bba83 commit 0f2fe67

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ PHP NEWS
1818
- LDAP:
1919
. Fixed bug GH-16032 (Various NULL pointer dereferencements in
2020
ldap_modify_batch()). (Girgias)
21+
. Fixed bug GH-16101 (Segfault in ldap_list(), ldap_read(), and ldap_search()
22+
when LDAPs array is not a list). (Girgias)
2123

2224
- OpenSSL:
2325
. Fixed stub for openssl_csr_new. (Jakub Zelenka)

ext/ldap/ldap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,11 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
15031503
ret = 0;
15041504
goto cleanup;
15051505
}
1506+
if (!zend_array_is_list(Z_ARRVAL_P(link))) {
1507+
zend_argument_value_error(1, "must be a list");
1508+
ret = 0;
1509+
goto cleanup;
1510+
}
15061511

15071512
if (base_dn_ht) {
15081513
nbases = zend_hash_num_elements(base_dn_ht);

ext/ldap/tests/gh16101.phpt

Lines changed: 25 additions & 0 deletions
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)