]> granicus.if.org Git - php/commitdiff
Fixed removing all controls by passing an empty array to ldap_set_option
authorCôme Chilliet <mcmic@php.net>
Tue, 11 Jul 2017 14:12:40 +0000 (16:12 +0200)
committerCôme Chilliet <mcmic@php.net>
Tue, 11 Jul 2017 14:18:33 +0000 (16:18 +0200)
ext/ldap/ldap.c
ext/ldap/tests/ldap_get_option_controls.phpt

index 98f1b38f0170f94b6256f69d66cbeda7c8396aa6..a710025af09b24c9d06c4e7addbb401c23779f60 100644 (file)
@@ -2540,10 +2540,11 @@ PHP_FUNCTION(ldap_set_option)
                        int ncontrols;
                        char error=0;
 
-                       if ((Z_TYPE_P(newval) != IS_ARRAY) || !(ncontrols = zend_hash_num_elements(Z_ARRVAL_P(newval)))) {
-                               php_error_docref(NULL, E_WARNING, "Expected non-empty array value for this option");
+                       if (Z_TYPE_P(newval) != IS_ARRAY) {
+                               php_error_docref(NULL, E_WARNING, "Expected array value for this option");
                                RETURN_FALSE;
                        }
+                       ncontrols = zend_hash_num_elements(Z_ARRVAL_P(newval));
                        ctrls = safe_emalloc((1 + ncontrols), sizeof(*ctrls), 0);
                        *ctrls = NULL;
                        ctrlp = ctrls;
index 2ec87ebac2ec05e48060716d4f1c71c7ba8fb75f..3b55685d5e8f23f42eec7de3dcf4352512946e52 100644 (file)
@@ -43,7 +43,9 @@ var_dump(
        $controls_get[0]['iscritical'],
        bin2hex($controls_get[0]['value']),
        $result = ldap_search($link, $base, "(objectClass=person)", array('cn')),
-       ldap_get_entries($link, $result)['count']
+       ldap_get_entries($link, $result)['count'],
+       ldap_set_option($link, LDAP_OPT_SERVER_CONTROLS, array()),
+       ldap_get_option($link, LDAP_OPT_SERVER_CONTROLS, $controls_get)
 );
 ?>
 ===DONE===
@@ -65,4 +67,6 @@ bool(true)
 string(14) "30050201010400"
 resource(%d) of type (ldap result)
 int(1)
+bool(true)
+bool(false)
 ===DONE===