|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-11-13 10:24 UTC] pecoes at web dot de
Description:
------------
The reproduce code is pretty straight-forward, which makes the issue look easy to avoid. My real problem, however, is more subtle:
I'm writing an extensible library. All my internal classes are __autoload'ed, but I want to treat all user-defined classes as tainted and load them manually:
Test.php:
<?php
class Tets {} // Note the typo!
?>
bug.php:
<?php
function __autoload ($class) {
require_once "$class.php";
}
function loadManually ($class) {
if (!php_check_syntax("$class.php")) {
throw new Exception("$class.php cannot be included");
}
// class_exists invokes __autoload and things go wrong
if (!class_exists($class)) {
throw new Exception("$class does not exist in $class.php");
}
}
loadManually("Test");
?>
Reproduce code:
---------------
$file = "Test.php";
if (!php_check_syntax($file)) {
die("$file cannot be included");
}
// the following line should do nothing!
require_once $file;
Expected result:
----------------
no crash
Actual result:
--------------
"Fatal Error: Cannot redeclare class..."
and then php(cli) crashes hard!
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 18:00:01 2025 UTC |
Reproducible both with 5.0 & 5.1 branches. Program received signal SIGSEGV, Segmentation fault. 0x00000006 in ?? () (gdb) bt #0 0x00000006 in ?? () #1 0x00000000 in ?? () #2 0xbfffbf30 in ?? () #3 0xbfffbf68 in ?? () #4 0xbfffbeec in ?? () #5 0x00000001 in ?? () #6 0x08226ebb in yy_chk () #7 0xbfffbf68 in ?? () #8 0x08188964 in zif_class_exists (ht=-1073758484, return_value=0x1, this_ptr=0x8226ebb, return_value_used=-1073758360) at /home/dev/php-src/Zend/zend_builtin_functions.c:907 Previous frame inner to this frame (corrupt stack?) Reproduce code could be safely reduced to this: <? function __autoload ($class) { require_once "$class.php"; } php_check_syntax("Test.php"); class_exists("Test"); ?>