Bug #74999 [Ver->Dup]: Exception::__toString truncates message at null byte

From: Date: Wed, 06 Dec 2017 22:56:02 +0000
Subject: Bug #74999 [Ver->Dup]: Exception::__toString truncates message at null byte
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212988@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: nikic@php.net Reported by: nobots dot nospam at example dot org Summary: Exception::__toString truncates message at null byte -Status: Verified +Status: Duplicate Type: Bug Package: *General Issues PHP Version: Irrelevant Block user comment: N Private report: N New Comment: Duplicate of bug #70894. Previous Comments: ------------------------------------------------------------------------ [2017-08-12 14:42:39] 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-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

« previous php.bugs (#212988) next »