#27504 [Fbk->Opn]: call_user_func_array allows calling of private/protected methods
| From: | redeye at erisx dot de | Date: | Fri, 05 Mar 2004 12:00:34 +0000 |
| Subject: | #27504 [Fbk->Opn]: call_user_func_array allows calling of private/protected methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-55950@lists.php.net to get a copy of this message | ||
ID: 27504
User updated by: redeye at erisx dot de
Reported By: redeye at erisx dot de
-Status: Feedback
+Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Windows, Linux
-PHP Version: 5.0.0b4 (beta4)
+PHP Version: 5.0.0rc1-dev
New Comment:
Still the same results ( using the latest snapshot )
Previous Comments:
------------------------------------------------------------------------
[2004-03-05 03:37:25] derick@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
------------------------------------------------------------------------
[2004-03-05 03:21:36] redeye at erisx dot de
Description:
------------
Using call_user_func_array you are able to call a private or protected
method of any object. I think this should not be allowed as it will
lead to bad programming style as you could use this bug to access
methods which should be hidden.
Reproduce code:
---------------
<?php
class foo {
function __construct () {
$this->bar('1');
}
private function bar ( $param ) {
echo 'Called function foo:bar('.$param.');<br>';
}
}
$foo = new foo();
call_user_func_array( array( $foo , 'bar' ) , array( '2' ) );
$foo->bar('3');
?>
Expected result:
----------------
Called function foo:bar(1);
Fatal error: Call to private method foo::bar() from context '' in
/www/htdocs/bug.php on line 14
Actual result:
--------------
Called function foo:bar(1);
Called function foo:bar(2);
Fatal error: Call to private method foo::bar() from context '' in
/www/htdocs/bug.php on line 17
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27504&edit=1