php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52785 CGI: error_log may result in output before the headers
Submitted: 2010-09-06 18:27 UTC Modified: 2010-09-07 00:14 UTC
From: cataphract@php.net Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.3.3 OS: Debian Lenny
Private report: No CVE-ID: None
 [2010-09-06 18:27 UTC] cataphract@php.net
Description:
------------
A call to error_log may result in data being output before the headers, thereby corrupting the response.

The same doesn't happen with other PHP output functions.

The ini directive error_log is set to "no value". The docs say "If this directive is not set, errors are sent to the SAPI error logger".

Test script:
---------------
<?php
error_log("oops");
echo "content";
inexistent_function(); //fatal; no problem


Expected result:
----------------
X-Powered-By: PHP/5.3.3
Content-type: text/html

oops
content<br />
<b>Fatal error</b>:  Call to undefined function inexistent_function() in <b>/home/glopes/test.php</b> on line <b>4</b><br />


Actual result:
--------------
$ /opt/php5/bin/php-cgi test.php
oops
X-Powered-By: PHP/5.3.3
Content-type: text/html

content<br />
<b>Fatal error</b>:  Call to undefined function inexistent_function() in <b>/home/glopes/test.php</b> on line <b>4</b><br />


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-09-07 00:14 UTC] johannes@php.net
-Status: Open +Status: Bogus
 [2010-09-07 00:14 UTC] johannes@php.net
PHP sends error_log() data via STDERR. RFC 3875 specifies the exact rules as system-dependent, PHP chose to use only STDOUT for CGI communication.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC