php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8744 call to header() causes CGI error
Submitted: 2001-01-16 14:07 UTC Modified: 2002-06-18 18:20 UTC
Votes:6
Avg. Score:4.7 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:5 (100.0%)
Same OS:5 (100.0%)
From: emily at crytech dot com Assigned:
Status: Not a bug Package: IIS related
PHP Version: 4.1.1 OS: Windows 2000
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: emily at crytech dot com
New email:
PHP Version: OS:

 

 [2001-01-16 14:07 UTC] emily at crytech dot com
Our situation is similar to that in bug report 8571, particularly situations 1 and 2. After adding, updating or deleting a record to a MSSQL database, the user is referred to this function (stored in file which is included in each page):

function pageRedirect($inURL) {
  header("Location: $inURL"); 
  exit;  
}

$inURL is never exactly the same as the current URL - either you are redirected to a completely different file name, or to the same file name with a different query string appended.

The record modification part always completes successfully in MSSQL, and the header() function sends the user to the new URL, but this error occurs:

[start]
CGI ERROR
CGI application misbehaved by not returning a complete set of headers. The headers that it
did return are:
[end]

... and any code in the page that the user has been redirected to is NOT executed. If the user clicks refresh, it does and all is well. 

This is a PHP web application being ported from a Linux/mySQL environment, where it works, so it appears to be an IIS-specific issue.

Thanks in advance for any feedback.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-16 14:12 UTC] derick@php.net
Can you tell us what is in the logs of IIS?
 [2001-01-16 18:29 UTC] emily at crytech dot com
A few more things: the problem is not easily reproducible. Also, if I change all of the database calls to go to mySQL (which I have installed on Windows 2000) instead of SQL Server 2000 (which is the database system I was using, also installed on the same machine), I do NOT get the CGI errors. However, in both instances, the databases do get updated or otherwise manipulated successfully; it's just the redirect that fails when using SQL Server. Hope this helps.
 [2001-01-16 18:30 UTC] emily at crytech dot com
In case you missed my second message:

Here are two typical lines from the IIS error log: the first is a successful page load (code 200) and the second is the CGI error after the redirect (502) Note that in the IIS log format it is normal for a space to separate the URL
and the Querystring. The last column in the log is the referrer URL.

2001-01-16 17:20:30 192.168.1.29 - GET /success/ProbRev.php3 EmpID=5&New=Y
200 0 378 Mozilla/4.0+(compatible;+MSIE+5.5;+Windows+98;+Win+9x+4.90)
http://192.168.1.30/success/InterimRevSelect.php3?EmpID=5

2001-01-16 17:20:30 192.168.1.29 - GET /success/ProbRev.php3
EmpID=5&ProbRevID=12 502 0 374
Mozilla/4.0+(compatible;+MSIE+5.5;+Windows+98;+Win+9x+4.90)
http://192.168.1.30/success/InterimRevSelect.php3?EmpID=5

 [2001-02-12 17:30 UTC] phanto@php.net
i have the same problem here. when i turn on the log startup errors flag in the php.ini i get the following output :
______________

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:


FATAL:  erealloc():  Unable to allocate 1043162510 bytes

______________

i guess there's something wrong within the parser or compiler, because nothing of the code is executed.

unfortunatelly i don't have 1GB RAM so i would be happy if there is any solution to this.

harald.

 [2002-01-12 06:55 UTC] lobbin@php.net
How does this work on 4.1.1?
 [2002-02-02 06:39 UTC] sander@php.net
No feedback was provided for this bug, so it is being suspended.
If you are able to provide the information that was requested,
please do so and change the status of the bug back to "Open".
 [2002-02-15 18:24 UTC] michael at webmtj dot com
I have tried 4.1.1 with win2k and the bug still exists.
 [2002-02-16 05:15 UTC] sander@php.net
Reopening.
 [2002-02-16 05:20 UTC] imajes@php.net
This problem also occurs when using apache, and a real url as opposed to a relative url (ie, having the php.exe engine exposed in the docroot).

I cannot determine if it's the same cause, but it's definitely the same symptom.

if this could get fixed, it'd fix a big security hole we have now.

james.
 [2002-03-12 15:41 UTC] sabram at NO-SPAM dot telus dot net
Hi All,

I also have this problem and it is definately related to MSSQL because I also used the same code with a MySQL database and the error doesn't exist.

Thanks,

Steve
 [2002-03-14 06:52 UTC] stain at NOSPAM_studenti dot it
i noticed various problem working on header() function.
in the worst case i get out a segmentation fault on my linux 2.4.4 running apache 1.3.22 + php 4.1.1

i will post a new bug thread about it in few minutes...

bye, stain
 [2002-03-18 17:15 UTC] php at gustl dot at
I read your errors and found:

FATAL:  erealloc():  Unable to allocate 1043162510 bytes

this seems to me like a MSSQL-PHP issue which comes along with the use of MSSQLs NTEXT and NVARCHAR Fields, after connecting to the MSSQL-database you must launch a SQL statement which limits the returning size fo this fields eg. 'SET TEXTSIZE 100000'.

hope this helps

Gustav Graf
 [2002-03-25 02:57 UTC] develop at kiumars-ansari dot de
Hi to all,

I have one Point to add. I use two copies of a WebSite on a Server running IIS (Test & Real). One of them dosn't have this Problem at all, but the Second one Produces this error. Both use the same Database Server. I compared the IIS Web Configuration, but both are the same! I can not find the error!

Kiumars Ansari / Hamburg
 [2002-03-25 09:11 UTC] sesser@php.net
Guys try 4.1.2 

I think this is just the 1000th duplicate of the header bug.
 [2002-04-28 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-06-02 16:16 UTC] k.schroeder@php.net
Same problem as #9852.

Regards, Kai
 [2002-06-18 18:20 UTC] sniper@php.net
See explanation in #9852
 [2004-07-26 22:21 UTC] perl at zeno dot com
This bug does not seem exclusive to PHP.

I'm having the same problem on IIS6/Win2003 using ActivePerl 5.8.4.  I'm using the CGI.pm module to generate a redirect header, I've also tried generating it manually, no difference.

I noticed the relationship to the DB connection as well, using the Win32::ODBC module.  However, I've managed to trace it down to an even simpler form.

If I redirect to a static HTML page, it works fine every time.  If I redirect to another Perl script, it fails intermittently with 502 errors in the IIS log.

If I copy the test scripts to an XP Workstation box with IIS 5.1, the problem simply does not occur, ever.

Here's another twist:  The problem only happens if the IIS6/Win2003 server is set to allow anonymous access.  If you disable anonymous access and the user has to authenticate to see the pages, it does not occur!
 [2004-07-27 00:49 UTC] perl at zeno dot com
I have posted a more thorough explanation in #9852.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Dec 02 14:05:53 2022 UTC