tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saravanan Bellan <Saravanan.Bel...@veritas.com>
Subject [PATCH] - JTC - Http11Processor.java
Date Wed, 16 Apr 2003 02:09:09 GMT
This is a fix when the content-length is invalid or greater than
Integer.MAX_VALUE.
What was happening was when such a condition happens the Http11Processor
exits abruptly
leaving a dirty Request object(which has the invalid content length) and
when the
Request object is used for any futher request , the same exception is
returned.
To reproduce send a request with content-length < 0 or > Integer.MAX_VALUE.

Also, is there any proposal for the Changing the content length in the 
Servlet specification from Integer to Long?

Thanks,

The following patch is also attached with the mail.


Index: Http11Processor.java
===================================================================
RCS file:
/home/cvspublic/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/
http11/Http11Processor.java,v
retrieving revision 1.63
diff -u -r1.63 Http11Processor.java
--- Http11Processor.java	23 Mar 2003 18:58:29 -0000	1.63
+++ Http11Processor.java	16 Apr 2003 01:52:57 -0000
@@ -959,11 +959,19 @@
         InputFilter[] inputFilters = inputBuffer.getFilters();
 
         // Parse content-length header
-        int contentLength = request.getContentLength();
-        if (contentLength >= 0) {
-            inputBuffer.addActiveFilter
-                (inputFilters[Constants.IDENTITY_FILTER]);
-            contentDelimitation = true;
+        int contentLength = 0;
+
+        try {
+            contentLength = request.getContentLength();
+            if (contentLength >= 0) {
+                inputBuffer.addActiveFilter
+                    (inputFilters[Constants.IDENTITY_FILTER]);
+                contentDelimitation = true;
+            }
+        } catch (Throwable t) {
+            // 400 - Invalid Request
+            error = true;
+            response.setStatus(400);
         }
 
         // Parse transfer-encoding header



Mime
View raw message