Author: remm
Date: Fri Jan  5 09:36:40 2018
New Revision: 1820272

URL: http://svn.apache.org/viewvc?rev=1820272&view=rev
Log:
Following a report on the user list, the "buffer full" check and clear seems 
misplaced for NIO2, and should happen before a read.

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java?rev=1820272&r1=1820271&r2=1820272&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java 
(original)
+++ tomcat/trunk/java/org/apache/tomcat/util/net/SecureNio2Channel.java Fri Jan 
 5 09:36:40 2018
@@ -300,7 +300,11 @@ public class SecureNio2Channel extends N
                         if (handshakeStatus == HandshakeStatus.NEED_TASK)
                             handshakeStatus = tasks();
                     } else if (handshake.getStatus() == 
Status.BUFFER_UNDERFLOW) {
-                        //read more data, reregister for OP_READ
+                        if (netInBuffer.position() == netInBuffer.limit()) {
+                            //clear the buffer if we have emptied it out on 
data
+                            netInBuffer.clear();
+                        }
+                        //read more data
                         if (async) {
                             sc.read(netInBuffer, socket, 
handshakeReadCompletionHandler);
                         } else {
@@ -499,10 +503,6 @@ public class SecureNio2Channel extends N
      * @throws IOException An IO error occurred
      */
     protected SSLEngineResult handshakeUnwrap() throws IOException {
-        if (netInBuffer.position() == netInBuffer.limit()) {
-            //clear the buffer if we have emptied it out on data
-            netInBuffer.clear();
-        }
         SSLEngineResult result;
         boolean cont = false;
         //loop while we can perform pure SSLEngine data

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1820272&r1=1820271&r2=1820272&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Jan  5 09:36:40 2018
@@ -104,6 +104,9 @@
         in the code that extracts the SNI information from a TLS handshake for
         the JSSE based NIO and NIO2 connectors. (markt)
       </fix>
+      <fix>
+        Fix NIO2 handshaking with a full input buffer. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">



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

Reply via email to