Bug #74999 [Ver]: Exception::__toString truncates message at null byte
| From: | ajf@php.net | Date: | Sat, 12 Aug 2017 14:42:42 +0000 |
| Subject: | Bug #74999 [Ver]: Exception::__toString truncates message at null byte | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-210632@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74999&edit=1
ID: 74999
Updated by: ajf@php.net
Reported by: nobots dot nospam at example dot org
Summary: Exception::__toString truncates message at null byte
Status: Verified
Type: Bug
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
i suspect this problem exists for some other places where errors are thrown, those all use C strings
a lot. For example, it probably happens with type declaration errors.
Previous Comments:
------------------------------------------------------------------------
[2017-07-28 09:24:43] kalle@php.net
Internally it comes down to the fact that the smartstr snprintf family function is not binary safe
------------------------------------------------------------------------
[2017-07-28 03:58:51] nobots dot nospam at example dot org
Description:
------------
Exception's message as string is truncated at the first occurrence of a null byte, notably a
problem when anonymous classes are involved, as their name does contain a null byte
thanks
Test script:
---------------
echo new Exception("XXXX " . get_class(new class{}) . " YYYY");
Expected result:
----------------
Exception: XXXX class@anonymous... YYYY in file:3
Stack trace:
#0 {main}
Actual result:
--------------
Exception: XXXX class@anonymous in /in/mft0e:3
Stack trace:
#0 {main}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74999&edit=1