Skip to content

Commit

Permalink
Fixed bug #77339 (__callStatic may get incorrect arguments)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstogov committed Dec 24, 2018
1 parent 64de5bc commit 7e597f4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 33 additions & 0 deletions Zend/tests/bug77339.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
--TEST--
Bug #77339 (__callStatic may get incorrect arguments)
--FILE--
<?php
class Foo
{
static function __callStatic($name, $arguments) {
if ($name === 'get') {
if (!isset($arguments[0])) {
var_dump(['getSomeWhat']);
var_dump($arguments);
exit;
}
}
echo "OK\n";
}

protected function get ($key) {
echo "BUG!!!\n";
}
}

class Bar
{
static function __callStatic($name, $arguments) {
echo Foo::get('getSomeWhat');
}
}

Bar::someUndefinedStaticFunction();
?>
--EXPECT--
OK
8 changes: 8 additions & 0 deletions Zend/zend_compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}

Expand Down

0 comments on commit 7e597f4

Please sign in to comment.