Author: csutherl
Date: 2015-04-29 14:17:42 -0400 (Wed, 29 Apr 2015)
New Revision: 2610
Modified:
tags/JBOSSWEB_2_1_12_GA_patch03/
tags/JBOSSWEB_2_1_12_GA_patch03/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
Log:
[JBPAPP-11219] create one-off patch branch
Property changes on: tags/JBOSSWEB_2_1_12_GA_patch03
___________________________________________________________________
Added: svn:mergeinfo
+ /branches/2.1.x:2609
Modified:
tags/JBOSSWEB_2_1_12_GA_patch03/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
===================================================================
---
tags/JBOSSWEB_2_1_12_GA_patch03/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2015-04-29
18:10:42 UTC (rev 2609)
+++
tags/JBOSSWEB_2_1_12_GA_patch03/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java 2015-04-29
18:17:42 UTC (rev 2610)
@@ -101,6 +101,11 @@
*/
protected boolean needCRLFParse = false;
+ /**
+ * Flag that indicates if an error has occurred.
+ */
+ private boolean error;
+
// ------------------------------------------------------------- Properties
@@ -122,6 +127,8 @@
if (endChunk)
return -1;
+ checkError();
+
if (needCRLFParse) {
needCRLFParse = false;
// FIXME: parse CRLF could return 0 in NB
@@ -221,6 +228,7 @@
lastValid = 0;
endChunk = false;
needCRLFParse = false;
+ error = false;
}
@@ -275,6 +283,7 @@
// In non blocking mode, no new chunk follows, even if data was present
int n = readBytes();
if (n < 0) {
+ error = true;
throw new IOException("Invalid chunk header");
} else if (n == 0) {
return false;
@@ -286,6 +295,9 @@
eol = true;
} else if (buf[pos] == Constants.SEMI_COLON) {
trailer = true;
+ } else if (buf[pos] < 0) {
+ error = true;
+ throw new IOException("Invalid chunk header");
} else if (!trailer) {
//don't read data after the trailer
if (HexUtils.DEC[buf[pos]] != -1) {
@@ -295,6 +307,7 @@
} else {
//we shouldn't allow invalid, non hex characters
//in the chunked header
+ error = true;
throw new IOException("Invalid chunk header");
}
}
@@ -303,8 +316,10 @@
}
- if (!readDigit || (result < 0))
+ if (readDigit == 0 || (result < 0)) {
+ error = true;
throw new IOException("Invalid chunk header");
+ }
if (result == 0)
endChunk = true;
@@ -328,17 +343,26 @@
while (!eol) {
if (pos >= lastValid) {
- if (readBytes() <= 0)
+ if (readBytes() <= 0) {
+ error = true;
throw new IOException("Invalid CRLF");
+ }
}
if (buf[pos] == Constants.CR) {
- if (crfound) throw new IOException("Invalid CRLF, two CR characters
encountered.");
+ if (crfound) {
+ error = true;
+ 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.");
+ if (!crfound) {
+ error = true;
+ throw new IOException("Invalid CRLF, no CR character
encountered.");
+ }
eol = true;
} else {
+ error = true;
throw new IOException("Invalid CRLF");
}
@@ -362,5 +386,11 @@
}
+
+ private void checkError() throws IOException {
+ if (error) {
+ throw new IOException("Chunked input filter error");
+ }
+ }
}
Show replies by date