1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Fixed GH-18902: ldap_exop/ldap_exop_sync assert triggered on empty request OID

close GH-18903
This commit is contained in:
David Carlier
2025-06-22 08:00:08 +01:00
parent a36b8fdc94
commit 2694eb9df0
3 changed files with 40 additions and 1 deletions

4
NEWS
View File

@@ -10,6 +10,10 @@ PHP NEWS
. Fix memory leaks when returning refcounted value from curl callback.
(nielsdos)
- LDAP:
. Fixed GH-18902 ldap_exop/ldap_exop_sync assert triggered on empty
request OID. (David Carlier)
- Streams:
. Fixed GH-13264 (fgets() and stream_get_line() do not return false on filter
fatal error). (Jakub Zelenka)

View File

@@ -4036,7 +4036,12 @@ static void php_ldap_exop(INTERNAL_FUNCTION_PARAMETERS, bool force_sync) {
LDAPControl **lserverctrls = NULL;
int rc, msgid;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OS|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "OP|S!a!zz", &link, ldap_link_ce, &reqoid, &reqdata, &serverctrls, &retdata, &retoid) != SUCCESS) {
RETURN_THROWS();
}
if (ZSTR_LEN(reqoid) == 0) {
zend_argument_value_error(2, "must not be empty");
RETURN_THROWS();
}

View File

@@ -0,0 +1,30 @@
--TEST--
GH-17704 (ldap_search fails when $attributes contains a non-packed array with numerical keys)
--EXTENSIONS--
ldap
--FILE--
<?php
$conn = ldap_connect();
try {
ldap_exop($conn,"\0");
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
ldap_exop_sync($conn,"");
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
try {
ldap_exop_sync($conn,"test\0");
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
ldap_exop(): Argument #2 ($request_oid) must not contain any null bytes
ldap_exop_sync(): Argument #2 ($request_oid) must not be empty
ldap_exop_sync(): Argument #2 ($request_oid) must not contain any null bytes