Bug #71572 [NEW]: String offset assignment from an empty string inserts null byte
From: francois
Operating system: Any
PHP version: 7.0.3
Package: Strings related
Bug Type: Bug
Bug description:String offset assignment from an empty string inserts null byte
Description:
------------
When assigning to a string offset from an empty string, the
corresponding byte is set to a null value.
In zend_assign_to_string_offset(), the length of the input string should
be checked. If 0, a warning should be raised and the string shouldn't be
modified.
Test script:
---------------
$str = "abc";
$str{0} = "";
var_dump($str);
Expected result:
----------------
PHP Fatal error: Uncaught Error: Cannot assign an empty string to a
string offset in ...
Actual result:
--------------
string(3) "bc" (read as "\0bc")
--
Edit bug report at https://bugs.php.net/bug.php?id=71572&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71572&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71572&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71572&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71572&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71572&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71572&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71572&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71572&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71572&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71572&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71572&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71572&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71572&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71572&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71572&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71572&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71572&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71572&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71572&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71572&r=mysqlcfg
Thread (3 messages)
- francois@php.net