com php-src: Avoid returning iscritical field when parsing response controls: ext/ldap/ldap.c ext/ldap/tests/ldap_add_ext.php t
ext/ldap/tests/ldap_delete_ext.phpt ext/ldap/tests/ ldap_mod_ext.phpt ext/ldap/tests/ldap_parse_result _controls.phpt
| From: | Côme Bernigaud | Date: | Thu, 21 Sep 2017 08:05:42 +0000 |
| Subject: | com php-src: Avoid returning iscritical field when parsing response controls: ext/ldap/ldap.c ext/ldap/tests/ldap_add_ext.php t ext/ldap/tests/ldap_delete_ext.phpt ext/ldap/tests/ ldap_mod_ext.phpt ext/ldap/tests/ldap_parse_result _controls.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99485@lists.php.net to get a copy of this message | ||
Commit: 9c7666d93acfd8f767ab36911ca46aa529b9593d
Author: Côme Chilliet <mcmic@php.net> Tue, 12 Sep 2017 12:04:17 +0200
Parents: d8a7214d8ce244b9e27650e147931ddb162b70c7
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=9c7666d93acfd8f767ab36911ca46aa529b9593d
Log:
Avoid returning iscritical field when parsing response controls
As stated in RFC4511 Section 4.1.11, this field is always false in
response controls and only makes sense in request controls
Changed paths:
M ext/ldap/ldap.c
M ext/ldap/tests/ldap_add_ext.phpt
M ext/ldap/tests/ldap_delete_ext.phpt
M ext/ldap/tests/ldap_mod_ext.phpt
M ext/ldap/tests/ldap_parse_result_controls.phpt
Diff:
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c
index a491678..bfa6af2 100644
--- a/ext/ldap/ldap.c
+++ b/ext/ldap/ldap.c
@@ -137,12 +137,15 @@ static void _free_ldap_result_entry(zend_resource *rsrc) /* {{{ */
/* }}} */
/* {{{ Parse controls from and to arrays */
-static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array)
+static void _php_ldap_control_to_array(LDAP *ld, LDAPControl* ctrl, zval* array, int request)
{
array_init(array);
add_assoc_string(array, "oid", ctrl->ldctl_oid);
- add_assoc_bool(array, "iscritical", (ctrl->ldctl_iscritical != 0));
+ if (request) {
+ /* iscritical field only makes sense in request controls (which may be obtained by
ldap_get_option) */
+ add_assoc_bool(array, "iscritical", (ctrl->ldctl_iscritical != 0));
+ }
// If it is a known oid, parse to values
if (strcmp(ctrl->ldctl_oid, LDAP_CONTROL_PASSWORDPOLICYRESPONSE) == 0) {
@@ -413,7 +416,7 @@ failure:
return -1;
}
-static void _php_ldap_controls_to_array(LDAP *ld, LDAPControl** ctrls, zval* array)
+static void _php_ldap_controls_to_array(LDAP *ld, LDAPControl** ctrls, zval* array, int request)
{
zval tmp1;
LDAPControl **ctrlp;
@@ -424,7 +427,7 @@ static void _php_ldap_controls_to_array(LDAP *ld, LDAPControl** ctrls, zval* arr
}
ctrlp = ctrls;
while (*ctrlp != NULL) {
- _php_ldap_control_to_array(ld, *ctrlp, &tmp1);
+ _php_ldap_control_to_array(ld, *ctrlp, &tmp1, request);
add_next_index_zval(array, &tmp1);
ctrlp++;
}
@@ -2966,7 +2969,7 @@ PHP_FUNCTION(ldap_get_option)
}
RETURN_FALSE;
}
- _php_ldap_controls_to_array(ld->link, ctrls, retval);
+ _php_ldap_controls_to_array(ld->link, ctrls, retval, 1);
} break;
/* options not implemented
case LDAP_OPT_API_INFO:
@@ -3201,7 +3204,7 @@ PHP_FUNCTION(ldap_parse_result)
/* Reverse -> fall through */
switch (myargcount) {
case 7:
- _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls);
+ _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0);
case 6:
zval_ptr_dtor(referrals);
array_init(referrals);
@@ -4109,7 +4112,7 @@ PHP_FUNCTION(ldap_exop_passwd)
}
if (myargcount > 4) {
- _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls);
+ _php_ldap_controls_to_array(ld->link, lserverctrls, serverctrls, 0);
}
ldap_memfree(lgenpasswd.bv_val);
diff --git a/ext/ldap/tests/ldap_add_ext.phpt b/ext/ldap/tests/ldap_add_ext.phpt
index aa08afd...a7a13d0 100644
--- a/ext/ldap/tests/ldap_add_ext.phpt
+++ b/ext/ldap/tests/ldap_add_ext.phpt
@@ -44,11 +44,9 @@ int(0)
string(0) ""
array(1) {
[0]=>
- array(3) {
+ array(2) {
["oid"]=>
string(14) "1.3.6.1.1.13.2"
- ["iscritical"]=>
- bool(false)
["value"]=>
array(2) {
["dn"]=>
diff --git a/ext/ldap/tests/ldap_delete_ext.phpt b/ext/ldap/tests/ldap_delete_ext.phpt
index 6f48cb2..f27523d 100644
--- a/ext/ldap/tests/ldap_delete_ext.phpt
+++ b/ext/ldap/tests/ldap_delete_ext.phpt
@@ -46,11 +46,9 @@ int(0)
string(0) ""
array(1) {
[0]=>
- array(3) {
+ array(2) {
["oid"]=>
string(14) "1.3.6.1.1.13.1"
- ["iscritical"]=>
- bool(false)
["value"]=>
array(3) {
["dn"]=>
diff --git a/ext/ldap/tests/ldap_mod_ext.phpt b/ext/ldap/tests/ldap_mod_ext.phpt
index 3f161f3..9c1cdf2 100644
--- a/ext/ldap/tests/ldap_mod_ext.phpt
+++ b/ext/ldap/tests/ldap_mod_ext.phpt
@@ -64,11 +64,9 @@ int(0)
string(0) ""
array(2) {
[0]=>
- array(3) {
+ array(2) {
["oid"]=>
string(14) "1.3.6.1.1.13.1"
- ["iscritical"]=>
- bool(false)
["value"]=>
array(1) {
["dn"]=>
@@ -76,11 +74,9 @@ array(2) {
}
}
[1]=>
- array(3) {
+ array(2) {
["oid"]=>
string(14) "1.3.6.1.1.13.2"
- ["iscritical"]=>
- bool(false)
["value"]=>
array(2) {
["dn"]=>
@@ -139,11 +135,9 @@ int(0)
string(0) ""
array(2) {
[0]=>
- array(3) {
+ array(2) {
["oid"]=>
string(14) "1.3.6.1.1.13.1"
- ["iscritical"]=>
- bool(false)
["value"]=>
array(2) {
["dn"]=>
@@ -156,11 +150,9 @@ array(2) {
}
}
[1]=>
- array(3) {
+ array(2) {
["oid"]=>
string(14) "1.3.6.1.1.13.2"
- ["iscritical"]=>
- bool(false)
["value"]=>
array(1) {
["dn"]=>
diff --git a/ext/ldap/tests/ldap_parse_result_controls.phpt
b/ext/ldap/tests/ldap_parse_result_controls.phpt
index ef1dca8..d652f9c 100644
--- a/ext/ldap/tests/ldap_parse_result_controls.phpt
+++ b/ext/ldap/tests/ldap_parse_result_controls.phpt
@@ -19,7 +19,6 @@ var_dump(
$result = ldap_search($link, $dn, $filter, array('cn')),
ldap_parse_result($link, $result, $errcode, $dn, $errmsg, $refs, $ctrls),
$ctrls[0]['oid'],
- $ctrls[0]['iscritical'],
$ctrls[0]['value']['size'],
bin2hex($ctrls[0]['value']['cookie']),
ldap_get_entries($link, $result)['count']
@@ -38,7 +37,6 @@ bool(true)
resource(%d) of type (ldap result)
bool(true)
string(22) "1.2.840.113556.1.4.319"
-bool(false)
int(%d)
string(%d) "%s"
int(1)