|  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
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
 [2017-07-28 03:58 UTC] nobots dot nospam at example dot org
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


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}


Add a Patch

Pull Requests

Add a Pull Request


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