From 7e597f48e9fda982e930e4f617d2b2d98d8878a5 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 24 Dec 2018 13:22:43 +0300 Subject: [PATCH] Fixed bug #77339 (__callStatic may get incorrect arguments) --- NEWS | 1 + Zend/tests/bug77339.phpt | 33 +++++++++++++++++++++++++++++++++ Zend/zend_compile.c | 8 ++++++++ 3 files changed, 42 insertions(+) create mode 100644 Zend/tests/bug77339.phpt diff --git a/NEWS b/NEWS index e0b069b8536..c83c6c06620 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ PHP NEWS (Valentin V. Bartenev) . Fixed bug #76046 (PHP generates "FE_FREE" opcode on the wrong line). (Nikita) + . Fixed bug #77339 (__callStatic may get incorrect arguments). (Dmitry) - COM: . Fixed bug #77177 (Serializing or unserializing COM objects crashes). (cmb) diff --git a/Zend/tests/bug77339.phpt b/Zend/tests/bug77339.phpt new file mode 100644 index 00000000000..2e749bcd5a8 --- /dev/null +++ b/Zend/tests/bug77339.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #77339 (__callStatic may get incorrect arguments) +--FILE-- + +--EXPECT-- +OK diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ee40e9c982d..77702b3facf 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -4127,6 +4127,14 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type) /* {{ if (ce) { zend_string *lcname = Z_STR_P(CT_CONSTANT(opline->op2) + 1); fbc = zend_hash_find_ptr(&ce->function_table, lcname); + if (fbc && !(fbc->common.fn_flags & ZEND_ACC_PUBLIC)) { + if (ce != CG(active_class_entry) + &&((fbc->common.fn_flags & ZEND_ACC_PRIVATE) + || !zend_check_protected(zend_get_function_root_class(fbc), CG(active_class_entry)))) { + /* incompatibe function */ + fbc = NULL; + } + } } }