|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-31 21:44 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 09:00:01 2025 UTC |
Description: ------------ In the below testcode, PHP5 & PHP6 outputs differ for is_callable() function. In PHP6 when we are echo-ing a string( eg. "welcome\0" ) with null character at the end of the string, the output with run-tests shows null character also at the end of the string. Whereas, running the file with php5.2.2 gives the expected output ( i.e "welcome"). is_callable() function in PHP 5 is incorrectly truncating the name passed when it calls ZVAL_STRING, i.e it should be possible to have function names with embedded nulls. The behavior on PHP6 looks be correct. This is consistent with the expected behaviour after reading Sarah Goleman's book; page 25. It says: "What's worth noting about PHP string is that the length of the string is always explicitly stated in the zval structure. This allows strings to contain NULL bytes without being truncated. This aspect of PHP strings will be referred to hereafter as binary safety because it makes it safe to contain any type of binary data." Reproduce code: --------------- <?php $undef_functions = array ( "\0", '\0', "welcome\0", 'welcome\0', ); $counter = 1; foreach($undef_functions as $func) { echo "-- Iteration $counter --\n"; var_dump( is_callable($func, FALSE, $callable_name) ); echo $callable_name, "\n"; $counter++; } echo "done"; ?> Expected result: ---------------- -- Iteration 1 -- bool(false) _ -- Iteration 2 -- bool(false) \0 -- Iteration 3 -- bool(false) welcome_ -- Iteration 4 -- bool(false) welcome\0 done Actual result: -------------- -- Iteration 1 -- bool(false) -- Iteration 2 -- bool(false) \0 -- Iteration 3 -- bool(false) welcome -- Iteration 4 -- bool(false) welcome\0 done