You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2016/06/17 19:04:42 UTC
[2/2] activemq-artemis git commit: ARTEMIS-570 Fix buffer size
overflow ProtonHandler
ARTEMIS-570 Fix buffer size overflow ProtonHandler
There is a race condition in the ProtonHandlerImpl.outputBuffer()
method. The method checks to see how many bytes (n) are pending in the
underlying ProtonJ buffer, then creates a Netty buffer of size n. It
then writes the contents of the pending ProtonJ head. However, ProtonJ
can still write to it's internal buffer, meaning that it's buffer.size >
n causing an illegalArgumentException. This patch fixes it by only
writing 'n' bytes to the Netty buffer.
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/432e2ce1
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/432e2ce1
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/432e2ce1
Branch: refs/heads/master
Commit: 432e2ce17849ed18ac9dd1d79ea2e935c160da3e
Parents: 07b57e5
Author: Martyn Taylor <mt...@redhat.com>
Authored: Thu Jun 16 16:02:23 2016 +0100
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Jun 17 15:04:32 2016 -0400
----------------------------------------------------------------------
.../main/java/org/proton/plug/handler/impl/ProtonHandlerImpl.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/432e2ce1/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/handler/impl/ProtonHandlerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/handler/impl/ProtonHandlerImpl.java b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/handler/impl/ProtonHandlerImpl.java
index d145a83..cbc993a 100644
--- a/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/handler/impl/ProtonHandlerImpl.java
+++ b/artemis-protocols/artemis-proton-plug/src/main/java/org/proton/plug/handler/impl/ProtonHandlerImpl.java
@@ -259,6 +259,7 @@ public class ProtonHandlerImpl extends ProtonInitializable implements ProtonHand
ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(size);
ByteBuffer head = transport.head();
head.position(offset);
+ head.limit(offset + size);
buffer.writeBytes(head);
offset += size; // incrementing offset for future calls
return buffer;