com php-src: Fixed removing all controls by passing an empty array to ldap_set_option: ext/ldap/ldap.c ext/ldap/tests/lda p_get_option_controls.phpt
| From: | Côme Bernigaud | Date: | Tue, 11 Jul 2017 14:18:33 +0000 |
| Subject: | com php-src: Fixed removing all controls by passing an empty array to ldap_set_option: ext/ldap/ldap.c ext/ldap/tests/lda p_get_option_controls.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98517@lists.php.net to get a copy of this message | ||
Commit: a148ee8c7c2c7aeb6195d8c9fb60464a967608c9
Author: Côme Chilliet <mcmic@php.net> Tue, 11 Jul 2017 16:12:40 +0200
Parents: 4219ca966ed052393e6209e14a5e39c1669e28a4
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=a148ee8c7c2c7aeb6195d8c9fb60464a967608c9
Log:
Fixed removing all controls by passing an empty array to ldap_set_option
Changed paths:
M ext/ldap/ldap.c
M ext/ldap/tests/ldap_get_option_controls.phpt
Diff:
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index 98f1b38..a710025 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 2ec87eb..3b55685 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===