php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #74999 Exception::__toString truncates message at null byte
Submitted: 2017-07-28 03:58 UTC Modified: 2017-12-06 22:56 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: nobots dot nospam at example dot org Assigned:
Status: Duplicate Package: *General Issues
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
7 - 3 = ?
Subscribe to this entry?

 
 [2017-07-28 03:58 UTC] 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}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-07-28 09:24 UTC] kalle@php.net
-Status: Open +Status: Verified
 [2017-07-28 09:24 UTC] kalle@php.net
Internally it comes down to the fact that the smartstr snprintf family function is not binary safe
 [2017-08-12 14:42 UTC] ajf@php.net
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.
 [2017-12-06 22:56 UTC] nikic@php.net
-Status: Verified +Status: Duplicate
 [2017-12-06 22:56 UTC] nikic@php.net
Duplicate of bug #70894.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 01:01:28 2024 UTC