Skip to content

Commit 2694eb9

Browse files
committed
Fixed GH-18902: ldap_exop/ldap_exop_sync assert triggered on empty request OID
close GH-18903
1 parent a36b8fd commit 2694eb9

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Fix memory leaks when returning refcounted value from curl callback.
1111
(nielsdos)
1212

13+
- LDAP:
14+
. Fixed GH-18902 ldap_exop/ldap_exop_sync assert triggered on empty
15+
request OID. (David Carlier)
16+
1317
- Streams:
1418
. Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter
1519
fatal error). (Jakub Zelenka)

ext/ldap/ldap.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4036,7 +4036,12 @@ static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) {
40364036
LDAPControl **lserverctrls = NULL;
40374037
int rc, msgid;
40384038

4039-
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
4039+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
4040+
RETURN_THROWS();
4041+
}
4042+
4043+
if (ZSTR_LEN(reqoid) == 0) {
4044+
zend_argument_value_error(2, "must not be empty");
40404045
RETURN_THROWS();
40414046
}
40424047

ext/ldap/tests/gh18902.phpt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
--TEST--
2+
GH-17704 (ldap_search fails when $attributes contains a non-packed array with numerical keys)
3+
--EXTENSIONS--
4+
ldap
5+
--FILE--
6+
<?php
7+
$conn = ldap_connect();
8+
9+
try {
10+
ldap_exop($conn,"\0");
11+
} catch (\ValueError $e) {
12+
echo $e->getMessage(), PHP_EOL;
13+
}
14+
15+
try {
16+
ldap_exop_sync($conn,"");
17+
} catch (\ValueError $e) {
18+
echo $e->getMessage(), PHP_EOL;
19+
}
20+
21+
try {
22+
ldap_exop_sync($conn,"test\0");
23+
} catch (\ValueError $e) {
24+
echo $e->getMessage(), PHP_EOL;
25+
}
26+
?>
27+
--EXPECTF--
28+
ldap_exop(): Argument #2 ($request_oid) must not contain any null bytes
29+
ldap_exop_sync(): Argument #2 ($request_oid) must not be empty
30+
ldap_exop_sync(): Argument #2 ($request_oid) must not contain any null bytes

0 commit comments

Comments
 (0)