ID:               41546
 Updated by:       [EMAIL PROTECTED]
 Reported By:      mahesh dot vemula at in dot ibm dot com
 Status:           Open
 Bug Type:         Strings related
 Operating System: RHEL4
 PHP Version:      5.2.2
 New Comment:

>is_callable() function in PHP 5 is incorrectly truncating the name
passed when it calls ZVAL_STRING

Well, the problem is that zend_is_callable() in PHP5 operates on
strings, not zvals (like in PHP6, which is just a sideffect of having
two types of strings), so there is no way to know the length of the
resulting string except to use strlen().

>i.e it should be possible to have function names with embedded nulls.

Functions with embedded nulls make no sense to me.

So the bottom line is:
function names with NULLs are not supported in both PHP5 and PHP6, but
PHP6 just happens to handle them correctly.
I'd say this is a "won't fix".


Previous Comments:
------------------------------------------------------------------------

[2007-05-31 06:29:53] mahesh dot vemula at in dot ibm dot com

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=41546&edit=1

Reply via email to