Description:
------------
mb_strcut() returns garbage when the following conditions are met:
1. The value specified to length parameter exceeds the length of the subject
string.
2. mbstring.internal_encoding is set to some single-byte encoding.
The garbage may consist of uncleared part of the heap that has previously been
used for some purpose, which could lead to unexpected information exposure.
This bug was originally reported by Mateusz Kocielski.
Test script:
---------------
<?php
$b = "bbbbbbbbbbb";
str_repeat("THIS IS A SECRET MESSAGE, ISN'T IT?", 1);
$var3 = mb_strcut($b, 0, 1000);
echo $var3;
?>
Expected result:
----------------
bbbbbbbbbbb
Actual result:
--------------
bbbbbbbbbbb??????D$Ј=m???=m?(?=m?`?=m??5<m??=m?THIS IS A SECRET MESSAGE, ISN'T
IT??g?1@?=m?(?=m???=m?p?=m?var3