From:             trevor at corevx dot com
Operating system: Solaris / OS X
PHP version:      5.2.1
PHP Bug Type:     Strings related
Bug description:  addcslashes has unexpected behavior with binary input / 
string terminator

Description:
------------
When the input to addcslashes contains a NULL character (string
terminator, \000) the resulting output is terminated at that point if the
NULL character is not deliberately escaped.  

This makes it impossible to use addcslashes for certain special cases with
binary data.  If fixed it would be a much more powerful tool.

Reproduce code:
---------------
# Last pair demonstrates issue

$str = "a\000z";

echo $str;                                # => az
strlen( $str );                           # => 3

addslashes( $str );                       # => a\0z
strlen( addslashes( $str ) );             # => 4

addcslashes( $str, "\000z" );             # => a\000\z
strlen( addcslashes( $str, "\000z" ) );   # => 7

addcslashes( $str, "z" );                 # => a
strlen( addcslashes( $str, "z" ) );       # => 1

Expected result:
----------------
echo addcslashes( $str, "z" );            # => a\z
strlen( addcslashes( $str, "z" ) );       # => 4


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

Reply via email to