From: fischikowski at web dot de
Operating system: Windows Vista 32bit
PHP version: 5.2.9
PHP Bug Type: Scripting Engine problem
Bug description: code-execution dependent on echo
Description:
------------
The echo ""; affects the "return true;" below.
As long as the echo is there everything works as expected, if you put "//"
in front of the echo, the return will be called even if it should not.
Reproduce code:
---------------
function matchHostList($host, $list_file) {
$host = explode(".", $host);
//$list_contents = explode("\n", file_get_contents($list_file));
$list_contents = array("www.google.de");
foreach($list_contents as $list_host) {
$list_host = explode(".", rtrim($list_host));
//if the list-host is more specific than the tested host we
can't match
if(count($host) < count($list_host))
continue;
for($i = 1;$i<=count($list_host) && $i <= count($host);$i++) {
if($list_host[count($list_host)-$i] !=
$host[count($host)-$i])
continue 2;
}
echo ""; //this is necessary to avoid wrong return
return true;
}
return false;
}
echo matchHostList("false.google.de", "")?"true":"false";
Expected result:
----------------
When running as shown above this returns false (because "continue 2;"
continues the loop above the "return true;"), this is OK.
If you remove the echo ""; above the "return true;" You would expect that
nothing changes (because we only removed some null-output), but in fact the
return value changes to true.
Actual result:
--------------
see Expected result
--
Edit bug report at http://bugs.php.net/?id=47576&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47576&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47576&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47576&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47576&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47576&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47576&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47576&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47576&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47576&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47576&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47576&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47576&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47576&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47576&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47576&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47576&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47576&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47576&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47576&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47576&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47576&r=mysqlcfg