com php-src: Fixed bug #76869 (Incorrect bypassing protected method accessibilty check).: NEWS Zend/tests/bug76869.phpt Zend/zend_object_handlers.c
| From: | Dmitry Stogov | Date: | Wed, 12 Sep 2018 09:16:50 +0000 |
| Subject: | com php-src: Fixed bug #76869 (Incorrect bypassing protected method accessibilty check).: NEWS Zend/tests/bug76869.phpt Zend/zend_object_handlers.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-103077@lists.php.net to get a copy of this message | ||
Commit: 655a99d1312b3dfd72a1b9e59b7b9322203f615b
Author: Dmitry Stogov <dmitry@zend.com> Wed, 12 Sep 2018 12:16:50 +0300
Parents: 58735c59b1ce333c4e4c4a56e9262587262e5ede
Branches: PHP-7.3
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=655a99d1312b3dfd72a1b9e59b7b9322203f615b
Log:
Fixed bug #76869 (Incorrect bypassing protected method accessibilty check).
Bugs:
https://bugs.php.net/76869
Changed paths:
M NEWS
A Zend/tests/bug76869.phpt
M Zend/zend_object_handlers.c
Diff:
diff --git a/NEWS b/NEWS
index 555cadd..c99e0fd 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? ????, PHP 7.3.0RC2
+- Core:
+ . Fixed bug #76869 (Incorrect bypassing protected method accessibilty check).
+ (Dmitry)
13 Sep 2018, PHP 7.3.0RC1
diff --git a/Zend/tests/bug76869.phpt b/Zend/tests/bug76869.phpt
new file mode 100644
index 0000000..ba963d4
--- /dev/null
+++ b/Zend/tests/bug76869.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #76869 (Incorrect bypassing protected method accessibilty check)
+--FILE--
+<?php
+class A {
+ private function f() {
+ return "A";
+ }
+}
+class B extends A {
+ protected function f() {
+ return "B";
+ }
+}
+$b = new B();
+try {
+ var_dump($b->f());
+} catch (Throwable $e) {
+ echo "Exception: ", $e->getMessage(), "\n";
+}
+?>
+--EXPECT--
+Exception: Call to protected method B::f() from context ''
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index aa2f5be..b10e5af 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1243,12 +1243,17 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr,
zend_string *
*/
scope = zend_get_executed_scope();
- if (fbc->op_array.fn_flags & ZEND_ACC_CHANGED) {
- zend_function *priv_fbc = zend_get_parent_private(scope, fbc->common.scope, lc_method_name);
- if (priv_fbc) {
- fbc = priv_fbc;
+ do {
+ if (fbc->op_array.fn_flags & ZEND_ACC_CHANGED) {
+ zend_function *priv_fbc = zend_get_parent_private(scope, fbc->common.scope, lc_method_name);
+ if (priv_fbc) {
+ fbc = priv_fbc;
+ break;
+ } else if (!(fbc->op_array.fn_flags & ZEND_ACC_PROTECTED)) {
+ break;
+ }
}
- } else {
+
/* Ensure that if we're calling a protected function, we're allowed to do so.
* If we're not and __call() handler exists, invoke it, otherwise error out.
*/
@@ -1260,7 +1265,7 @@ ZEND_API zend_function *zend_std_get_method(zend_object **obj_ptr, zend_string
*
fbc = NULL;
}
}
- }
+ } while (0);
}
if (UNEXPECTED(!key)) {