Author: markt Date: Tue Apr 15 10:10:30 2008 New Revision: 648337 URL: http://svn.apache.org/viewvc?rev=648337&view=rev Log: Fix bug 44620. Infinite loop in NIO connector.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.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=648337&r1=648336&r2=648337&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Tue Apr 15 10:10:30 2008 @@ -60,12 +60,6 @@ +1: markt, fhanik -1: -* Prevent the connector entering an infinite loop - https://issues.apache.org/bugzilla/show_bug.cgi?id=44620 - http://svn.apache.org/viewvc?rev=640572&view=rev - +1: markt, fhanik, pero - -1: - * Document missing secret attributes https://issues.apache.org/bugzilla/show_bug.cgi?id=44715 http://svn.apache.org/viewvc?rev=643497&view=rev Modified: tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java?rev=648337&r1=648336&r2=648337&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioOutputBuffer.java Tue Apr 15 10:10:30 2008 @@ -612,11 +612,21 @@ int total = 0; private synchronized void addToBB(byte[] buf, int offset, int length) throws IOException { - while (socket.getBufHandler().getWriteBuffer().remaining() < length) { - flushBuffer(); + while (length > 0) { + int thisTime = length; + if (socket.getBufHandler().getWriteBuffer().position() == + socket.getBufHandler().getWriteBuffer().capacity() + || socket.getBufHandler().getWriteBuffer().remaining()==0) { + flushBuffer(); + } + if (thisTime > socket.getBufHandler().getWriteBuffer().remaining()) { + thisTime = socket.getBufHandler().getWriteBuffer().remaining(); + } + socket.getBufHandler().getWriteBuffer().put(buf, offset, thisTime); + length = length - thisTime; + offset = offset + thisTime; + total += thisTime; } - socket.getBufHandler().getWriteBuffer().put(buf, offset, length); - total += length; NioEndpoint.KeyAttachment ka = (NioEndpoint.KeyAttachment)socket.getAttachment(false); if ( ka!= null ) ka.access();//prevent timeouts for just doing client writes } @@ -792,18 +802,7 @@ int len = chunk.getLength(); int start = chunk.getStart(); byte[] b = chunk.getBuffer(); - while (len > 0) { - int thisTime = len; - if (socket.getBufHandler().getWriteBuffer().position() == socket.getBufHandler().getWriteBuffer().capacity() ||socket.getBufHandler().getWriteBuffer().remaining()==0) { - flushBuffer(); - } - if (thisTime > socket.getBufHandler().getWriteBuffer().remaining()) { - thisTime = socket.getBufHandler().getWriteBuffer().remaining(); - } - addToBB(b,start,thisTime); - len = len - thisTime; - start = start + thisTime; - } + addToBB(b, start, len); return chunk.getLength(); } 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=648337&r1=648336&r2=648337&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Tue Apr 15 10:10:30 2008 @@ -34,11 +34,9 @@ <body> <section name="Tomcat 6.0.17 (remm)"> <subsection name="Catalina"> - <changelog> + <changelog> <fix>ExtendedAccessLogValve cs-uri not print empty querystring (pero) </fix> - </changelog> - <changelog> <update> ServletContext.getResource("noslash/resource") only requires forward slash if STRICT_SERVLET_COMPLIANCE flag is set to true. This mimics the behavior of 6.0.15 and earlier. (fhanik) @@ -102,6 +100,9 @@ </fix> <fix> <bug>44494</bug>: Character input limited to 8KB. (remm) + </fix> + <fix> + <bug>44620</bug>: Infinite loop in NIO connector. (markt) </fix> </changelog> </subsection> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]