DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=32023>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=32023

CGIServlet fails to handle post message with multipart/form data

           Summary: CGIServlet fails to handle post message with
                    multipart/form data
           Product: Tomcat 5
           Version: 5.0.0
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Servlets:CGI
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Following error message appears in the log.
INFO: cgi: runCGI (stderr):CGI.pm: Server closed socket during multipart read 
(client aborted?).

The problem is that when creating the inputstream for cgi component there is 
only one single 'read' on the ServletInputStream, in reasonably large uploads 
this will not drain the buffer.

I have a pathch ready and it looks like this:

diff -u -r1.27 CGIServlet.java
--- CGIServlet.java     14 Oct 2004 08:14:47 -0000      1.27
+++ CGIServlet.java     2 Nov 2004 15:42:25 -0000
@@ -1691,7 +1691,12 @@
             ByteArrayOutputStream contentStream = null;
             if(!"".equals(sContentLength)) {
                 byte[] content = new byte[Integer.parseInt(sContentLength)];
-                int lenRead = stdin.read(content);
+                int lenRead = 0;
+                do {
+                    int partRead = stdin.read(
+                        content,lenRead,content.length-lenRead);
+                    lenRead += partRead;
+                } while (lenRead > 0 && lenRead < content.length);
                 contentStream = new ByteArrayOutputStream(
                         Integer.parseInt(sContentLength));
                 if ("POST".equals(env.get("REQUEST_METHOD"))) {

Hope someone can commit it to cvs repository.

Maybe there should be an initial parameter for the servlet also that restricts 
maximum size of the upload?


--
Antti

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to