From fb4f9566e85234d453dcf028cc9cf2bd9f701b18 Mon Sep 17 00:00:00 2001 From: fhanik Date: Tue, 8 Jan 2008 21:45:03 +0000 Subject: [PATCH] fix regression for bug 11117 while maintaining the no need to proceed and block for comet connections that handle chunked input git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@610173 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/coyote/http11/filters/ChunkedInputFilter.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java index 78ede731f..98e0a0dbf 100644 --- a/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java +++ b/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java @@ -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"); -- 2.11.0