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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: cataphract@php.net
New email:
PHP Version: OS:

 

 [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: Wed Apr 24 21:01:29 2024 UTC