2015-02-06 21:03 GMT+03:00  <ma...@apache.org>:
> Author: markt
> Date: Fri Feb  6 18:03:10 2015
> New Revision: 1657910
>
> URL: http://svn.apache.org/r1657910
> 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/tc7.0.x/trunk/   (props changed)
>     
> tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java
>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

> Modified: 
> tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java
> URL: 
> http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java?rev=1657910&r1=1657909&r2=1657910&view=diff
> ==============================================================================
> --- 
> tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java 
> (original)
> +++ 
> tomcat/tc7.0.x/trunk/java/org/apache/coyote/http11/AbstractInputBuffer.java 
> Fri Feb  6 18:03:10 2015
> @@ -278,15 +278,10 @@ public abstract class AbstractInputBuffe
>          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
> @@ -295,12 +290,9 @@ public abstract class AbstractInputBuffe
>          }
>
>          // Reset pointers
> -        lastValid = lastValid - pos;
> -        pos = 0;
>          lastActiveFilter = -1;
>          parsingHeader = true;
>          swallowInput = true;
> -
>      }

The old code always sets  pos=0 as a result of this method.

The new code does not reset lastValid and pos in case when pos ==
lastValid and both are > 0.

It shall be

        if (lastValid - pos > 0 && pos > 0) {
            System.arraycopy(buf, pos, buf, 0, lastValid - pos);
        }
        lastValid = lastValid - pos;
        pos = 0;


Tomcat 6 has the same implementation of nextRequest() in its
InternalInputBuffer, Internal(Nio|Apr)InputBuffer classes.


Trunk buildbot
It did not notice this, though failed for a different reason (supposedly),
1)
http://ci.apache.org/projects/tomcat/tomcat9/logs/1657907/TEST-org.apache.tomcat.websocket.TestWebSocketFrameClientSSL.NIO2.txt
- failed. expected:<100000> but was:<144>

2)
TestResponsePerformance - as expected

Tomcat 8 buildbot
1)
http://ci.apache.org/projects/tomcat/tomcat8/logs/1657908/TEST-org.apache.catalina.connector.TestInputBuffer.BIO.txt
- an odd error. There are several other errors
2)
http://ci.apache.org/projects/tomcat/tomcat8/logs/1657908/TEST-org.apache.tomcat.websocket.TestWsWebSocketContainer.BIO.txt
- many failures (NIO, NIO2 -OK)
3)
TestAsyncContextImpl, TestMapperPerformance - timing failure, as usual.



Tomcat 7 buildbot
Broken. It cannot delete old directories to start a new build.

Best regards,
Konstantin Kolinko

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

Reply via email to