Author: markt Date: Fri Feb 6 17:58:12 2015 New Revision: 1657907 URL: http://svn.apache.org/r1657907 Log: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=57544 Fix potential infinite loop if pos == 0 Only need to update lastValid & pos if bytes have been moved.
Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java Modified: tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java?rev=1657907&r1=1657906&r2=1657907&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java (original) +++ tomcat/trunk/java/org/apache/coyote/http11/Http11InputBuffer.java Fri Feb 6 17:58:12 2015 @@ -348,15 +348,10 @@ public class Http11InputBuffer implement request.recycle(); // Copy leftover bytes to the beginning of the buffer - if (lastValid - pos > 0) { - int npos = 0; - int opos = pos; - while (lastValid - opos > opos - npos) { - System.arraycopy(buf, opos, buf, npos, opos - npos); - npos += pos; - opos += pos; - } - System.arraycopy(buf, opos, buf, npos, lastValid - opos); + if (lastValid - pos > 0 && pos > 0) { + System.arraycopy(buf, pos, buf, 0, lastValid - pos); + lastValid = lastValid - pos; + pos = 0; } // Recycle filters @@ -365,8 +360,6 @@ public class Http11InputBuffer implement } // Reset pointers - lastValid = lastValid - pos; - pos = 0; lastActiveFilter = -1; parsingHeader = true; swallowInput = true; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org