Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@www.apache.org Received: (qmail 17216 invoked from network); 2 Nov 2004 15:47:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 2 Nov 2004 15:47:07 -0000 Received: (qmail 52628 invoked by uid 500); 2 Nov 2004 15:46:51 -0000 Delivered-To: apmail-jakarta-tomcat-dev-archive@jakarta.apache.org Received: (qmail 52585 invoked by uid 500); 2 Nov 2004 15:46:50 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 52572 invoked by uid 99); 2 Nov 2004 15:46:50 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [192.18.33.10] (HELO exchange.sun.com) (192.18.33.10) by apache.org (qpsmtpd/0.28) with SMTP; Tue, 02 Nov 2004 07:46:50 -0800 Received: (qmail 18998 invoked by uid 50); 2 Nov 2004 15:46:48 -0000 Date: 2 Nov 2004 15:46:48 -0000 Message-ID: <20041102154648.18997.qmail@nagoya.betaversion.org> From: bugzilla@apache.org To: tomcat-dev@jakarta.apache.org Cc: Subject: DO NOT REPLY [Bug 32023] New: - CGIServlet fails to handle post message with multipart/form data X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT . 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: tomcat-dev@jakarta.apache.org ReportedBy: ag_tomcat_dev@hotmail.com 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: tomcat-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org