PHP :: Bug #40915 :: addcslashes has unexpected behavior with binary input
| Bug #40915 | addcslashes has unexpected behavior with binary input / string terminator | ||||
|---|---|---|---|---|---|
| Submitted: | 2007-03-26 06:06 UTC | Modified: | 2007-03-26 10:28 UTC | ||
| From: | trevor at corevx dot com | Assigned: | tony2001 (profile) | ||
| Status: | Closed | Package: | Strings related | ||
| PHP Version: | 5.2.1 | OS: | Solaris / OS X | ||
| Private report: | No | CVE-ID: | None | ||
[2007-03-26 06:06 UTC] trevor at corevx dot com
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
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2007-03-26 10:28 UTC] tony2001@php.net