#48665 [NEW]: class_alias allows impossible classes
| From: | dams@php.net | Date: | Tue, 23 Jun 2009 16:29:37 +0000 |
| Subject: | #48665 [NEW]: class_alias allows impossible classes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-138707@lists.php.net to get a copy of this message | ||
From: dams@php.net
Operating system: Mac OS X Server 10.5.6
PHP version: 5.3.0RC4
PHP Bug Type: Class/Object related
Bug description: class_alias allows impossible classes
Description:
------------
The original class is checked, but the checks a too lax on the alias
itself.
I suggest the alias's name should follow the same rules as the class
itself.
Admittedly, the following may work in conjunction with the problem
reported :
<?php
class foo { }
var_dump(class_alias('foo', '$$$'));
$b = "$$$";
$a = new $b;
var_dump($a);
?>
Reproduce code:
---------------
<?php
class foo { }
var_dump(class_alias('foo', '999'));
var_dump(class_alias('foo', ''));
var_dump(class_alias('foo', true));
var_dump(class_alias('foo', false));
var_dump(class_alias('foo', null));
var_dump(class_alias('foo', '$$$'));
var_dump(class_alias('foo', ';;'));
var_dump(class_alias('foo', '"'));
var_dump(class_alias('foo', '::'));
?>
Expected result:
----------------
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
bool(false)
Actual result:
--------------
bool(true)
bool(true)
bool(true)
PHP Warning: Cannot redeclare class in /Users/alterway/bin/php-
5.3.0RC4/Zend/tests/- on line 8
Warning: Cannot redeclare class in /Users/alterway/bin/php-
5.3.0RC4/Zend/tests/- on line 8
bool(false)
PHP Warning: Cannot redeclare class in /Users/alterway/bin/php-
5.3.0RC4/Zend/tests/- on line 9
Warning: Cannot redeclare class in /Users/alterway/bin/php-
5.3.0RC4/Zend/tests/- on line 9
bool(false)
bool(true)
bool(true)
bool(true)
bool(true)
--
Edit bug report at http://bugs.php.net/?id=48665&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48665&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48665&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48665&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48665&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48665&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48665&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48665&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48665&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48665&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48665&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48665&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48665&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48665&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48665&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48665&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48665&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48665&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48665&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48665&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48665&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48665&r=mysqlcfg