From 088d8dc0d4611ebb36443a9aa8724f2d6776befd Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Tue, 24 Feb 2009 02:25:04 +0000
Subject: [PATCH] Add unit test for Issue 3805 (SASL phase2). Also, fix buffer overflow in SASL Byte Channel found by the test.

---
 opends/src/server/org/opends/server/extensions/SASLByteChannel.java |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/SASLByteChannel.java b/opends/src/server/org/opends/server/extensions/SASLByteChannel.java
index 0d8555f..7498594 100644
--- a/opends/src/server/org/opends/server/extensions/SASLByteChannel.java
+++ b/opends/src/server/org/opends/server/extensions/SASLByteChannel.java
@@ -92,7 +92,8 @@
       this.saslContext = saslContext;
       this.channel = connection.getChannel();
       this.readBuffer = ByteBuffer.allocate(connection.getAppBufferSize());
-      this.decodeBuffer = ByteBuffer.allocate(connection.getAppBufferSize());
+      this.decodeBuffer =
+                ByteBuffer.allocate(connection.getAppBufferSize() + lengthSize);
     }
 
     /**
@@ -217,7 +218,7 @@
       //The buffer length is greater than what is there, save what is there,
       //figure out how much more is needed and return.
       if(bufLength > readBuffer.position()) {
-        neededBytes = bufLength - readBuffer.position() + 4;
+        neededBytes = bufLength - readBuffer.position() + lengthSize;
         readBuffer.flip();
         decodeBuffer.put(readBuffer);
         readBuffer.clear();

--
Gitblit v1.10.0