Skip to content

Commit 66f16f4

Browse files
committed
Merge branch 'PHP-8.0'
* Fix crash in LDAP search functions during argument validation * Fix ldap_next_entry() parameter name
2 parents 87b263d + 465aa1d commit 66f16f4

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

ext/ldap/ldap.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,11 +1602,15 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
16021602

16031603
if (!base_dn_str) {
16041604
zend_argument_type_error(2, "must be of type string when argument #1 ($ldap) is a resource");
1605+
ret = 0;
1606+
goto cleanup;
16051607
}
16061608
ldap_base_dn = zend_string_copy(base_dn_str);
16071609

16081610
if (!filter_str) {
16091611
zend_argument_type_error(3, "must be of type string when argument #1 ($ldap) is a resource");
1612+
ret = 0;
1613+
goto cleanup;
16101614
}
16111615
ldap_filter = zend_string_copy(filter_str);
16121616

ext/ldap/ldap.stub.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ function ldap_first_entry($ldap, $result) {}
7070

7171
/**
7272
* @param resource $ldap
73-
* @param resource $result
73+
* @param resource $entry
7474
* @return resource|false
7575
*/
76-
function ldap_next_entry($ldap, $result) {}
76+
function ldap_next_entry($ldap, $entry) {}
7777

7878
/**
7979
* @param resource $ldap

ext/ldap/ldap_arginfo.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* This is a generated file, edit the .stub.php file instead.
2-
* Stub hash: 056fa51afdd7d40f9866ebd67837f5ddfa2c6236 */
2+
* Stub hash: 5cae0fbe180164126aa99ad5465822d87fe73fb9 */
33

44
#if defined(HAVE_ORALDAP)
55
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_connect, 0, 0, 0)
@@ -78,7 +78,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_first_entry, 0, 0, 2)
7878
ZEND_ARG_INFO(0, result)
7979
ZEND_END_ARG_INFO()
8080

81-
#define arginfo_ldap_next_entry arginfo_ldap_first_entry
81+
ZEND_BEGIN_ARG_INFO_EX(arginfo_ldap_next_entry, 0, 0, 2)
82+
ZEND_ARG_INFO(0, ldap)
83+
ZEND_ARG_INFO(0, entry)
84+
ZEND_END_ARG_INFO()
8285

8386
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_ldap_get_entries, 0, 2, MAY_BE_ARRAY|MAY_BE_FALSE)
8487
ZEND_ARG_INFO(0, ldap)

ext/ldap/tests/ldap_search_error.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ try {
3939
echo $exception->getMessage() . "\n";
4040
}
4141

42+
try {
43+
ldap_search($link, [], []);
44+
} catch (TypeError $exception) {
45+
echo $exception->getMessage() . "\n";
46+
}
47+
48+
try {
49+
ldap_search($link, "", []);
50+
} catch (TypeError $exception) {
51+
echo $exception->getMessage() . "\n";
52+
}
53+
4254
?>
4355
--EXPECTF--
4456
Warning: ldap_search(): Search: No such object in %s on line %d
@@ -49,3 +61,5 @@ bool(false)
4961
ldap_search(): Argument #1 ($ldap) cannot be empty
5062
ldap_search(): Argument #2 ($base) must have the same number of elements as the links array
5163
ldap_search(): Argument #3 ($filter) must have the same number of elements as the links array
64+
ldap_search(): Argument #2 ($base) must be of type string when argument #1 ($ldap) is a resource
65+
ldap_search(): Argument #3 ($filter) must be of type string when argument #1 ($ldap) is a resource

0 commit comments

Comments
 (0)