directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r159974 - directory/network/trunk/src/java/org/apache/mina/io/filter/SSLByteBufferPool.java directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
Date Mon, 04 Apr 2005 00:56:56 GMT
Author: trustin
Date: Sun Apr  3 17:56:55 2005
New Revision: 159974

URL: http://svn.apache.org/viewcvs?view=rev&rev=159974
Log:
Applied Janne's SSL filter patch that fixes: DIRMINA-14


Modified:
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLByteBufferPool.java
    directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLByteBufferPool.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLByteBufferPool.java?view=diff&r1=159973&r2=159974
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLByteBufferPool.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLByteBufferPool.java Sun
Apr  3 17:56:55 2005
@@ -75,8 +75,8 @@
 
             // application buffer size has been doubled because SSLEngine
             // returns BUFFER_OVERFLOW even if there is enough room for the buffer.
-            // So I doubled the size as a workaround.
-            appBufferSize = sslEngine.getSession().getApplicationBufferSize() * 2;
+            // So for now we use a size double the packet size as a workaround.
+            appBufferSize = packetBufferSize * 2;
             initiateBufferStacks();
             initiated = true;
         }

Modified: directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java?view=diff&r1=159973&r2=159974
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/io/filter/SSLHandler.java Sun Apr  3
17:56:55 2005
@@ -160,9 +160,14 @@
             // We have to expand inNetBuffer
             inNetBuffer = SSLByteBufferPool.expandBuffer( inNetBuffer,
                     2 * (inNetBuffer.position() + buf.limit()) );
+            // We also expand app. buffer (twice the size of in net. buffer)
+            appBuffer = SSLByteBufferPool.expandBuffer( appBuffer, inNetBuffer.capacity()
* 2);
+            appBuffer.position( 0 );
+            appBuffer.limit( 0 );
             if( parent.debug != null )
             {
                 parent.debug.print("expanded inNetBuffer:" + inNetBuffer);
+                parent.debug.print("expanded appBuffer:" + appBuffer);
             }
         }
 
@@ -261,6 +266,9 @@
 
         if( appBuffer.hasRemaining() )
         {
+             if ( parent.debug != null ) {
+                 parent.debug.print( "Error: appBuffer not empty!" );
+             }
             //still app data in buffer!?
             throw new IllegalStateException();
         }
@@ -279,7 +287,8 @@
             status != SSLEngineResult.Status.BUFFER_UNDERFLOW )
         {
             throw new SSLException( "SSLEngine error during decrypt: " +
-                                    status );
+                                    status +
+                                    " inNetBuffer: " + inNetBuffer + "appBuffer: " + appBuffer);
         }
         
         return status;
@@ -301,11 +310,11 @@
         // Loop until there is no more data in src
         while ( src.hasRemaining() ) {
 
-            if ( src.limit() > ( outNetBuffer.remaining() / 2 ) ) {
+            if ( src.remaining() > ( ( outNetBuffer.capacity() - outNetBuffer.position()
) / 2 ) ) {
                 // We have to expand outNetBuffer
                 // Note: there is no way to know the exact size required, but enrypted data
                 // shouln't need to be larger than twice the source data size?
-                outNetBuffer = SSLByteBufferPool.expandBuffer( outNetBuffer, src.limit()
* 2 );
+                outNetBuffer = SSLByteBufferPool.expandBuffer( outNetBuffer, src.capacity()
* 2 );
                 if ( parent.debug != null ) {
                     parent.debug.print( "expanded outNetBuffer:" + outNetBuffer );
                 }
@@ -322,13 +331,14 @@
                 }
             } else {
                 throw new SSLException( "SSLEngine error during encrypt: "
-                        + result.getStatus() );
+                        + result.getStatus() +
+                        " src: " + src + "outNetBuffer: " + outNetBuffer);
             }
         }
 
         outNetBuffer.flip();
     }
-    
+
     /**
      * Perform any handshaking processing.
      */



Mime
View raw message