From: Côme Chilliet Date: Tue, 11 Jul 2017 14:12:40 +0000 (+0200) Subject: Fixed removing all controls by passing an empty array to ldap_set_option X-Git-Tag: php-7.2.0beta1~73 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a148ee8c7c2c7aeb6195d8c9fb60464a967608c9;p=php Fixed removing all controls by passing an empty array to ldap_set_option --- diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index 98f1b38f01..a710025af0 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -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; diff --git a/ext/ldap/tests/ldap_get_option_controls.phpt b/ext/ldap/tests/ldap_get_option_controls.phpt index 2ec87ebac2..3b55685d5e 100644 --- a/ext/ldap/tests/ldap_get_option_controls.phpt +++ b/ext/ldap/tests/ldap_get_option_controls.phpt @@ -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===