From b2d7e73dd458a99328b894b609d68d4c1fe7f436 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Sun, 25 Jan 2015 20:33:07 +0100 Subject: [PATCH] [#3375] Correctly calculate the endOffset when wrap multiple ByteBuffer Motivation: We failed to correctly calculate the endOffset when wrap multiple ByteBuffer and so not wrapped everything when an offset > 0 is used. Modifications: Correctly calculate endOffset. Result: All ByteBuffers are correctly wrapped when offset > 0. --- handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java b/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java index a42d0ed047..afcaf09e38 100644 --- a/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java +++ b/handler/src/main/java/io/netty/handler/ssl/OpenSslEngine.java @@ -427,7 +427,8 @@ public final class OpenSslEngine extends SSLEngine { // There was no pending data in the network BIO -- encrypt any application data int bytesConsumed = 0; - for (int i = offset; i < length; ++ i) { + int endOffset = offset + length; + for (int i = offset; i < endOffset; ++ i) { final ByteBuffer src = srcs[i]; while (src.hasRemaining()) {