Bug 32430 - CGI cannot process large content bodies (4.1.31 and 5.0.28)
Summary: CGI cannot process large content bodies (4.1.31 and 5.0.28)
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 4
Classification: Unclassified
Component: Servlets:CGI (show other bugs)
Version: 4.1.31
Hardware: PC Windows 2000
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-11-29 20:57 UTC by Mark Claassen
Modified: 2004-11-29 14:57 UTC (History)
0 users



Attachments
A working CGI servlet class (59.99 KB, text/plain)
2004-11-29 21:01 UTC, Mark Claassen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Claassen 2004-11-29 20:57:41 UTC
In addition to bug 32429, there are other issues I found with the CGI servlet.  
There was a type-o in sending the content to the process, a problem with 
printing debug output, and a problem processing large content.  The large 
content issue is the big one.

The problem is the existing 4.1.31 code is this:
     int lenRead = stdin.read(content);
when it should be in some sort of read loop to ensure all the data is read.  

I don't know if fix I did to the  toString() and blanksToString() is valid, but 
I was repeatedly getting:
java.lang.ClassCastException
        at dsi.app.tomcat.DCGIServlet$CGIEnvironment.toString
(DCGIServlet.java:1241)
        at dsi.app.tomcat.DCGIServlet.doGet(DCGIServlet.java:596)
        at dsi.app.tomcat.DCGIServlet.doPost(DCGIServlet.java:544)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...

Attached is the file I made to fix the issues we were having.  It is based on 
the 4.1.31 source code and a diff with tell what changes I made.  The 5.0.28 
source looks similar to the 4.1 source and so will have the problem as well.
Comment 1 Mark Claassen 2004-11-29 21:01:33 UTC
Created attachment 13584 [details]
A working CGI servlet class

Don't know what type of file a "patch" file is supposed to be, but this the fix
for the large file issue we were having.
Comment 2 Yoav Shapira 2004-11-29 21:04:07 UTC
Patches are supposed to be in diff -u format, not the whole file.  For this and 
other information, please read 
http://www.apache.org/dev/contributors.html#patches.
Comment 3 Mark Thomas 2004-11-29 23:57:23 UTC
Everything but the toString() issue has been fixed as a result of fixing other 
bugs. Fix for this has been applied to 4.1.x and 5.5.x

The root cause of the cast exception is at line 1710 (for CVS revision 1.31 in 
TC4.1.x) where the content length is added as an integer rather than as a 
string. I have fixed the root cause rather than apply your toString() changes.

Thanks again for your CGI bug reports. If you find any more, let us know.