Author: kkolinko Date: Mon Aug 27 23:11:20 2012 New Revision: 1377909 URL: http://svn.apache.org/viewvc?rev=1377909&view=rev Log: Merged revision 1377900 from tomcat/trunk: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42181 Better handling of edge conditions in chunk header processing.
Added: tomcat/tc7.0.x/trunk/test/org/apache/tomcat/util/buf/TestHexUtils.java - copied unchanged from r1377900, tomcat/trunk/test/org/apache/tomcat/util/buf/TestHexUtils.java Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Reverse-merged /tomcat/trunk:r1377904 Merged /tomcat/trunk:r1377900 Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java?rev=1377909&r1=1377908&r2=1377909&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java Mon Aug 27 23:11:20 2012 @@ -311,10 +311,11 @@ public class ChunkedInputFilter implemen trailer = true; } else if (!trailer) { //don't read data after the trailer - if (HexUtils.getDec(buf[pos]) != -1) { + int charValue = HexUtils.getDec(buf[pos]); + if (charValue != -1) { readDigit = true; result *= 16; - result += HexUtils.getDec(buf[pos]); + result += charValue; } else { //we shouldn't allow invalid, non hex characters //in the chunked header Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java?rev=1377909&r1=1377908&r2=1377909&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java (original) +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/buf/HexUtils.java Mon Aug 27 23:11:20 2012 @@ -34,22 +34,10 @@ public final class HexUtils { * Table for HEX to DEC byte translation. */ private static final int[] DEC = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 00, 01, 02, 03, 04, 05, 06, 07, 8, 9, -1, -1, -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, }; @@ -80,7 +68,12 @@ public final class HexUtils { } public static int getDec(int index){ - return DEC[index]; + // Fast for correct values, slower for incorrect ones + try { + return DEC[index - '0']; + } catch (ArrayIndexOutOfBoundsException ex) { + return -1; + } } public static byte getHex(int index){ Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1377909&r1=1377908&r2=1377909&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Aug 27 23:11:20 2012 @@ -199,6 +199,10 @@ shutdown. (markt) </fix> <fix> + <bug>42181</bug>: Better handling of edge conditions in chunk header + processing. (kkolinko) + </fix> + <fix> <bug>53697</bug>: Correct a regression in the fix for <bug>51881</bug> that mean that in some circumstances the <code>comet</code> flag was not reset on <code>HttpAprProcessor</code> instances. This caused problems --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org