fix regression for bug 11117 while maintaining the no need to proceed and block for...
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 8 Jan 2008 21:45:03 +0000 (21:45 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 8 Jan 2008 21:45:03 +0000 (21:45 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@610173 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/http11/filters/ChunkedInputFilter.java

index 78ede73..98e0a0d 100644 (file)
@@ -154,7 +154,14 @@ public class ChunkedInputFilter implements InputFilter {
             chunk.setBytes(buf, pos, remaining);
             pos = pos + remaining;
             remaining = 0;
-            needCRLFParse = true;
+            //we need a CRLF
+            if ((pos+1) >= lastValid) {   
+                //if we call parseCRLF we overrun the buffer here
+                //so we defer it to the next call BZ 11117
+                needCRLFParse = true;
+            } else {
+                parseCRLF(); //parse the CRLF immediately
+            }
         }
 
         return result;
@@ -311,6 +318,7 @@ public class ChunkedInputFilter implements InputFilter {
         throws IOException {
 
         boolean eol = false;
+        boolean crfound = false;
 
         while (!eol) {
 
@@ -320,7 +328,10 @@ public class ChunkedInputFilter implements InputFilter {
             }
 
             if (buf[pos] == Constants.CR) {
+                if (crfound) throw new IOException("Invalid CRLF, two CR characters encountered.");
+                crfound = true;
             } else if (buf[pos] == Constants.LF) {
+                if (!crfound) throw new IOException("Invalid CRLF, no CR character encountered.");
                 eol = true;
             } else {
                 throw new IOException("Invalid CRLF");