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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nobots dot nospam at example dot org
New email:
PHP Version: OS:

 

 [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

Pull Requests

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: Sun Dec 22 02:01:28 2024 UTC