Bug #78450 [Opn->Ver]: ldap_parse_result() sets size of LDAP Controll LDAP_CONTROL_PAGEDRESULTS to 0

From: Date: Sat, 24 Aug 2019 13:03:14 +0000
Subject: Bug #78450 [Opn->Ver]: ldap_parse_result() sets size of LDAP Controll LDAP_CONTROL_PAGEDRESULTS to 0
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222391@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78450&edit=1 ID: 78450 Updated by: cmb@php.net Reported by: kagome at opentrash dot com Summary: ldap_parse_result() sets size of LDAP Controll LDAP_CONTROL_PAGEDRESULTS to 0 -Status: Open +Status: Verified Type: Bug Package: LDAP related Operating System: Windows 10 / Server 2016 PHP Version: 7.3.8 Block user comment: N Private report: N New Comment: It seems to me that the implementation of ldap_parse_result() is severly broken, since it confuses zvals with completely unrelated types. Previous Comments: ------------------------------------------------------------------------ [2019-08-24 11:38:38] kagome at opentrash dot com Description: ------------ ldap_parse_result() sets "size" of LDAP Control LDAP_CONTROL_PAGEDRESULTS to 0 instead of keeping the old value. Test script: --------------- Basicly the Code is the same as here: https://www.php.net/manual/en/function.ldap-control-paged-result.php $searchValue = ldap_escape("P", null, LDAP_ESCAPE_FILTER); // Looking for Computers that has P in name (in my Case more than 2000) // $ldapconn is a valid link identifier for a directory server // $ldaptree is a valid ldaptree $serverctrls = array(); // I need paged results because the Active Directory shows only 1000 Entries max. $serverctrls[LDAP_CONTROL_PAGEDRESULTS] = array("oid" => LDAP_CONTROL_PAGEDRESULTS, "value" => array("size" => 999, "cookie" => "")); $resultData = array(); // Array to store all results do { var_dump($serverctrls); $result = ldap_search($ldapconn, $ldaptree, "(&(objectClass=person)(objectClass=user)(objectClass=organizationalPerson)(objectClass=computer)(|(samaccountname=*".$searchValue."*)(name=*".$searchValue."*)))", array("*"), // default Parameter https://www.php.net/manual/en/function.ldap-search.php 0, // default Parameter -1, // default Parameter -1, // default Parameter LDAP_DEREF_NEVER, // default Parameter $serverctrls); $errcode = $dn = $errmsg = $refs = null; ldap_parse_result($this->ldapconn, $result, $errcode, $dn, $errmsg, $refs ,$serverctrls); // this will update my LDAP Controlls $serverctrls with Cookie infos $data = ldap_get_entries($this->ldapconn, $result); for ($i=0; $i<$data["count"]; $i++) { array_push($resultData, $data[$i]); // push all single Entries to a big array } }while($serverctrls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] !== null && $serverctrls[LDAP_CONTROL_PAGEDRESULTS]['value']['cookie'] != ''); return $resultData; Expected result: ---------------- Check the var_dump line: On first run in do-Loop I expect: array(1) { ["1.2.840.113556.1.4.319"]=> array(2) { ["oid"]=> string(22) "1.2.840.113556.1.4.319" ["value"]=> array(2) { ["size"]=> int(999) ["cookie"]=> string(0) "" } } } on the second run in do-Loop I expect: array(1) { ["1.2.840.113556.1.4.319"]=> array(2) { ["oid"]=> string(22) "1.2.840.113556.1.4.319" ["value"]=> array(2) { ["size"]=> int(999) ["cookie"]=> string(0) "CookieContentInformation-bla" } } } So Cookie Information is filled. Actual result: -------------- What I get on second run in do-Loop is: array(1) { ["1.2.840.113556.1.4.319"]=> array(2) { ["oid"]=> string(22) "1.2.840.113556.1.4.319" ["value"]=> array(2) { ["size"]=> int(0) ["cookie"]=> string(0) "CookieContentInformation-bla" } } } Why is "size"-key now 0? ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78450&edit=1

« previous php.bugs (#222391) next »