From a148ee8c7c2c7aeb6195d8c9fb60464a967608c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?C=C3=B4me=20Chilliet?= Date: Tue, 11 Jul 2017 16:12:40 +0200 Subject: [PATCH] Fixed removing all controls by passing an empty array to ldap_set_option --- ext/ldap/ldap.c | 5 +++-- ext/ldap/tests/ldap_get_option_controls.phpt | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) 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=== -- 2.50.1