tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1196212 - in /tomcat/trunk/java/org/apache/coyote/http11: InternalNioInputBuffer.java LocalStrings.properties
Date Tue, 01 Nov 2011 19:04:36 GMT
Author: kkolinko
Date: Tue Nov  1 19:04:36 2011
New Revision: 1196212

URL: http://svn.apache.org/viewvc?rev=1196212&view=rev
Log:
Add additional state in HTTP Nio connector non-blocking HTTP headers parsing
as a self-guard against unexpected call to parseHeaders() after the parsing has already been
completed
without a prior call to recycle() or nextRequest().
One such occurrence was observed because of a bug that did not recycle the buffer and was
fixed a while ago.

The request will be rejected with error 400. The message is visible only with debug logging
in AbstractHttp11Processor.

Modified:
    tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
    tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties

Modified: tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?rev=1196212&r1=1196211&r2=1196212&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java Tue Nov  1 19:04:36
2011
@@ -88,7 +88,11 @@ public class InternalNioInputBuffer exte
         /**
          * Reading all bytes until the next CRLF. The line is being ignored.
          */
-        HEADER_SKIPLINE
+        HEADER_SKIPLINE,
+        /**
+         * Done parsing headers. Request body should follow.
+         */
+        HEADERS_DONE
     }
 
     // ----------------------------------------------------------- Constructors
@@ -469,6 +473,11 @@ public class InternalNioInputBuffer exte
     @Override
     public boolean parseHeaders()
         throws IOException {
+        if (headerParsePos == HeaderParsePosition.HEADERS_DONE) {
+            throw new IllegalStateException(
+                    sm.getString("iib.parseheaders.ise.error"));
+        }
+
         HeaderParseStatus status = HeaderParseStatus.HAVE_MORE_HEADERS;
 
         do {
@@ -527,6 +536,7 @@ public class InternalNioInputBuffer exte
                 // Skip
             } else if (chr == Constants.LF) {
                 pos++;
+                headerParsePos = HeaderParsePosition.HEADERS_DONE;
                 return HeaderParseStatus.DONE;
             } else {
                 break;

Modified: tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties?rev=1196212&r1=1196211&r2=1196212&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/coyote/http11/LocalStrings.properties Tue Nov  1 19:04:36
2011
@@ -28,4 +28,5 @@ http11processor.sendfile.error=Error sen
 iib.eof.error=Unexpected EOF read on the socket
 iib.invalidheader=The HTTP header line [{0}] does not conform to RFC 2616 and has been ignored.
 iib.invalidmethod=Invalid character (CR or LF) found in method name
+iib.parseheaders.ise.error=Unexpected state: headers already parsed. Buffer not recycled?
 iib.requestheadertoolarge.error=Request header is too large



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message