qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject qpid-broker-j git commit: QPID-7947 : [Java Broker] [AMQP 1.0] Improve handling of empty and overlarge frames
Date Mon, 02 Oct 2017 21:45:57 GMT
Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 526019c75 -> 66cef783f


QPID-7947 : [Java Broker] [AMQP 1.0] Improve handling of empty and overlarge frames


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/66cef783
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/66cef783
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/66cef783

Branch: refs/heads/master
Commit: 66cef783f63ceb0252fbf236ae0577aa5e14b23d
Parents: 526019c
Author: Rob Godfrey <rgodfrey@apache.org>
Authored: Mon Oct 2 23:45:33 2017 +0200
Committer: Rob Godfrey <rgodfrey@apache.org>
Committed: Mon Oct 2 23:45:33 2017 +0200

----------------------------------------------------------------------
 .../protocol/v1_0/framing/FrameHandler.java     | 52 +++++++++++++-------
 1 file changed, 34 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/66cef783/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java
----------------------------------------------------------------------
diff --git a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java
b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java
index 523aec1..6dd69bd 100644
--- a/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java
+++ b/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/framing/FrameHandler.java
@@ -72,12 +72,6 @@ public class FrameHandler implements ProtocolHandler
             {
 
                 size = in.getInt();
-                if(remaining < size)
-                {
-                    in.position(in.position()-4);
-                    break;
-                }
-                int dataOffset = (in.get() << 2) & 0x3FF;
 
                 if (size < 8)
                 {
@@ -97,6 +91,13 @@ public class FrameHandler implements ProtocolHandler
                     break;
                 }
 
+                if(remaining < size)
+                {
+                    in.position(in.position()-4);
+                    break;
+                }
+                int dataOffset = (in.get() << 2) & 0x3FF;
+
                 if (dataOffset < 8)
                 {
                     frameParsingError = createFramingError(
@@ -154,25 +155,40 @@ public class FrameHandler implements ProtocolHandler
 
                 try
                 {
-                    Object val = dup.hasRemaining() ? _valueHandler.parse(dup) : null;
-
-                    if (dup.hasRemaining())
+                    final boolean hasFrameBody = dup.hasRemaining();
+                    Object frameBody;
+                    if (hasFrameBody)
                     {
-                        if (val instanceof Transfer)
+                        frameBody = _valueHandler.parse(dup);
+                        if (dup.hasRemaining())
                         {
-                            final QpidByteBuffer payload = dup.slice();
-                            ((Transfer) val).setPayload(Collections.singletonList(payload));
-                            payload.dispose();
+                            if (frameBody instanceof Transfer)
+                            {
+                                final QpidByteBuffer payload = dup.slice();
+                                ((Transfer) frameBody).setPayload(Collections.singletonList(payload));
+                                payload.dispose();
+                            }
+                            else
+                            {
+                                frameParsingError = createFramingError(
+                                        "Frame length %d larger than contained frame body
%s.",
+                                        size,
+                                        frameBody);
+                                break;
+                            }
                         }
-                        else
+                    }
+                    else
+                    {
+                        frameBody = null;
+                        if(_isSasl)
                         {
                             frameParsingError = createFramingError(
-                                    "Frame length %d larger than contained frame body %s.",
-                                    size,
-                                    val);
+                                    "Empty (heartbeat) frames are not permitted during SASL
negotiation");
                             break;
                         }
                     }
+
                     channelFrameBodies.add(new ChannelFrameBody()
                     {
                         @Override
@@ -184,7 +200,7 @@ public class FrameHandler implements ProtocolHandler
                         @Override
                         public Object getFrameBody()
                         {
-                            return val;
+                            return frameBody;
                         }
                     });
                 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message