#27504 [Opn->Asn]: call_user_func_array allows calling of private/protected methods
| From: | derick@php.net | Date: | Fri, 05 Mar 2004 12:06:05 +0000 |
| Subject: | #27504 [Opn->Asn]: call_user_func_array allows calling of private/protected methods | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-55951@lists.php.net to get a copy of this message | ||
ID: 27504
Updated by: derick@php.net
Reported By: redeye at erisx dot de
-Status: Open
+Status: Assigned
Bug Type: Zend Engine 2 problem
Operating System: Windows, Linux
PHP Version: 5.0.0rc1-dev
-Assigned To:
+Assigned To: andi
New Comment:
Andi, worth fixing this? :)
Previous Comments:
------------------------------------------------------------------------
[2004-03-05 07:00:33] redeye at erisx dot de
Still the same results ( using the latest snapshot )
------------------------------------------------------------------------
[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