Author: markt
Date: Sun Mar 23 22:58:54 2014
New Revision: 1580654

URL: http://svn.apache.org/r1580654
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=53119
Make sure the NIO AJP output buffer is cleared on any error to prevent any 
possible overflow if it is written to again before the connection is closed. 
This extends the original fix for the APR/native output buffer to the NIO 
connector.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1346365

Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1580654&r1=1580653&r2=1580654&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Sun 
Mar 23 22:58:54 2014
@@ -290,16 +290,18 @@ public class AjpNioProcessor extends Abs
     @Override
     protected void output(byte[] src, int offset, int length)
             throws IOException {
+        
+        KeyAttachment att =
+                (KeyAttachment) socketWrapper.getSocket().getAttachment(false);
+        if ( att == null ) throw new IOException("Key must be cancelled");
+
         ByteBuffer writeBuffer =
                 socketWrapper.getSocket().getBufHandler().getWriteBuffer();
 
         writeBuffer.put(src, offset, length);
         
         writeBuffer.flip();
-        
-        KeyAttachment att =
-                (KeyAttachment) socketWrapper.getSocket().getAttachment(false);
-        if ( att == null ) throw new IOException("Key must be cancelled");
+
         long writeTimeout = att.getWriteTimeout();
         Selector selector = null;
         try {
@@ -311,9 +313,9 @@ public class AjpNioProcessor extends Abs
             pool.write(writeBuffer, socketWrapper.getSocket(), selector,
                     writeTimeout, true);
         }finally { 
+            writeBuffer.clear();
             if ( selector != null ) pool.put(selector);
         }
-        writeBuffer.clear();
     }
 
 

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=1580654&r1=1580653&r2=1580654&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sun Mar 23 22:58:54 2014
@@ -117,6 +117,12 @@
   <subsection name="Coyote">
     <changelog>
       <fix>
+        <bug>53119</bug>: Make sure the NIO AJP output buffer is cleared on any
+        error to prevent any possible overflow if it is written to again before
+        the connection is closed. This extends the original fix for the
+        APR/native output buffer to the NIO connector. (kkolinko)
+      </fix>
+      <fix>
         <bug>56172</bug>: Avoid possible request corruption when using the AJP
         NIO connector and a request is sent using more than one AJP message.
         Patch provided by Amund Elstad. (markt)



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

Reply via email to