You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/03/19 16:27:12 UTC

svn commit: r1579262 - in /tomcat/tc6.0.x/trunk: STATUS.txt java/org/apache/coyote/http11/filters/ChunkedInputFilter.java webapps/docs/changelog.xml

Author: markt
Date: Wed Mar 19 15:27:11 2014
New Revision: 1579262

URL: http://svn.apache.org/r1579262
Log:
Improve processing of chuck size from chunked headers. Avoid overflow and use a bit shift instead of a multiplication as it is marginally faster.

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1579262&r1=1579261&r2=1579262&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Wed Mar 19 15:27:11 2014
@@ -28,15 +28,6 @@ None
 PATCHES PROPOSED TO BACKPORT:
   [ New proposals should be added at the end of the list ]
 
-* Improve processing of chuck size from chunked headers. Avoid overflow and use
-  a bit shift instead of a multiplication as it is marginally faster.
-  http://people.apache.org/~markt/patches/2014-03-17-chunked-headers-tc6-v1.patch
-  +1: markt, kkolinko, remm
-  -1:
-  kkolinko: Technical notes:
-    1. r1578329 does not belong to svn:mergeinfo, that is an unrelated commit
-    2. changelog.xml part of the patch does not merge, because of later changes
-
 * Redefine the <code>globalXsltFile</code> initialisation parameter of the
   DefaultServlet as relative to CATALINA_BASE/conf or CATALINA_HOME/conf.
   Prevent user supplied XSLTs used by the DefaultServlet from defining external

Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java?rev=1579262&r1=1579261&r2=1579262&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/filters/ChunkedInputFilter.java Wed Mar 19 15:27:11 2014
@@ -303,7 +303,7 @@ public class ChunkedInputFilter implemen
 
         int result = 0;
         boolean eol = false;
-        boolean readDigit = false;
+        int readDigit = 0;
         boolean extension = false;
 
         while (!eol) {
@@ -325,10 +325,9 @@ public class ChunkedInputFilter implemen
             } else if (!extension) { 
                 //don't read data after the trailer
                 int charValue = HexUtils.getDec(buf[pos]);
-                if (charValue != -1) {
-                    readDigit = true;
-                    result *= 16;
-                    result += charValue;
+                if (charValue != -1 && readDigit < 8) {
+                    readDigit++;
+                    result = (result << 4) | charValue;
                 } else {
                     //we shouldn't allow invalid, non hex characters
                     //in the chunked header
@@ -352,7 +351,7 @@ public class ChunkedInputFilter implemen
 
         }
 
-        if (!readDigit)
+        if (readDigit == 0 || result < 0)
             return false;
 
         if (result == 0)

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1579262&r1=1579261&r2=1579262&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Wed Mar 19 15:27:11 2014
@@ -65,6 +65,15 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Coyote">
+    <changelog>
+      <fix>
+        Improve processing of chuck size from chunked headers. Avoid overflow
+        and use a bit shift instead of a multiplication as it is marginally
+        faster. (markt/kkolinko)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="Jasper">
     <changelog>
       <fix>



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


RE: svn commit: r1579262 - in /tomcat/tc6.0.x/trunk: STATUS.txt java/org/apache/coyote/http11/filters/ChunkedInputFilter.java webapps/docs/changelog.xml

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Christopher Schultz [mailto:chris@christopherschultz.net] 
> Subject: Re: svn commit: r1579262 - in /tomcat/tc6.0.x/trunk:
> STATUS.txt java/org/apache/coyote/http11/filters/ChunkedInputFilter.java
> webapps/docs/changelog.xml

> Bit-shifting is more than marginally faster than multiplication.

Not so much on modern CPUs.

> If the compiler is good, it will notice multiplication against a
> static power of two and make the switch for you. I'm not sure if
> the Java compiler is that smart.

It is.

 - Chuck




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


Re: svn commit: r1579262 - in /tomcat/tc6.0.x/trunk: STATUS.txt java/org/apache/coyote/http11/filters/ChunkedInputFilter.java webapps/docs/changelog.xml

Posted by Christopher Schultz <ch...@christopherschultz.net>.
Mark,

On 3/19/14, 11:27 AM, markt@apache.org wrote:
> Author: markt
> Date: Wed Mar 19 15:27:11 2014
> New Revision: 1579262
> 
> URL: http://svn.apache.org/r1579262
> Log:
> Improve processing of chuck size from chunked headers. Avoid overflow and use a bit shift instead of a multiplication as it is marginally faster.

Bit-shifting is more than marginally faster than multiplication. If the
compiler is good, it will notice multiplication against a static power
of two and make the switch for you. I'm not sure if the Java compiler is
that smart.

-chris