From:             mahesh dot vemula at in dot ibm dot com
Operating system: RHEL4
PHP version:      5.2.2
PHP Bug Type:     Strings related
Bug description:  Is_callable() function behavior incorrect in PHP5.

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 bug report at http://bugs.php.net/?id=41546&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41546&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41546&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41546&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41546&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41546&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41546&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41546&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41546&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41546&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41546&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41546&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41546&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41546&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41546&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41546&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41546&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41546&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41546&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41546&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41546&r=mysqlcfg

Reply via email to