|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-03-19 11:41 UTC] laruence@php.net
[2013-10-24 05:28 UTC] yohgaki@php.net
-Type: Bug
+Type: Documentation Problem
-Package: Scripting Engine problem
+Package: Documentation problem
[2013-10-24 05:28 UTC] yohgaki@php.net
[2013-10-24 05:30 UTC] yohgaki@php.net
[2013-10-30 00:42 UTC] spam2 at rhsoft dot net
[2013-11-01 06:34 UTC] yohgaki@php.net
-Type: Documentation Problem
+Type: Feature/Change Request
-Package: Documentation problem
+Package: *General Issues
[2013-11-01 06:34 UTC] yohgaki@php.net
[2016-09-04 14:22 UTC] yonelceruto at gmail dot com
[2021-07-19 14:00 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2021-07-19 14:00 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 15:00:02 2025 UTC |
Description: ------------ A string containing "\0" passed into error_log() causes the message to be truncated after that character. This is especially apparent when a log message contains a serialized object which has private properties, as their serialization key is \0classname\0propname. file_put_contents is not affected, nor is using error_log with the destination parameter; only when using the ini setting. Digging around through source, it looks like it's caused by the use of c strlen() in xbuf_format_converter (main/spprintf.c:576) which assumes null-terminated strings, called by vspprintf() -> ssprintf() -> php_log_err() Happens in 5.4.x as well as a just-built git master 5.6.0-dev Test script: --------------- <?php class a { private $b = 'c'; } $obj = new a; $str = serialize($obj); ini_set('error_log', '/Users/eric/Desktop/error_log.log'); error_log($str); // truncated file_put_contents('/Users/eric/Desktop/fpc.log', $str); // ok error_log($str, 3, '/Users/eric/Desktop/error_log_param.log'); // ok Expected result: ---------------- All three files should contain the following string: O:1:"a":1:{s:4:"ab";s:1:"c";} (note that "ab" is actually "\0a\0b") Hex dump: 4F 3A 31 3A 22 61 22 3A 31 3A 7B 73 3A 34 3A 22 00 61 00 62 22 3B 73 3A 31 3A 22 63 22 3B 7D Actual result: -------------- error_log.log contains only the following: [16-Mar-2013 04:23:06 UTC] O:1:"a":1:{s:4:" (the timestamp is not relevant) 4F 3A 31 3A 22 61 22 3A 31 3A 7B 73 3A 34 3A 22 0A The other two files (error_log_param.log, fpc.log) correctly record the full string.