Skip to content

Commit 45284cb

Browse files
Merge pull request #1930 from rabbitmq/mergify/bp/v5.x/pr-1927
Report a malformed frame in one more case (backport #1927)
2 parents 75cbc5d + e2c34e0 commit 45284cb

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/main/java/com/rabbitmq/client/impl/Frame.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ public static Frame readFrom(DataInputStream is, int maxPayloadSize) throws IOEx
109109

110110
channel = is.readUnsignedShort();
111111
int payloadSize = is.readInt();
112-
if (payloadSize >= maxPayloadSize) {
113-
throw new IllegalStateException(format(
114-
"Frame body is too large (%d), maximum configured size is %d. " +
112+
if (payloadSize < 0 || payloadSize >= maxPayloadSize) {
113+
throw new MalformedFrameException(format(
114+
"Frame body size is invalid (%d), maximum configured size is %d. " +
115115
"See ConnectionFactory#setMaxInboundMessageBodySize " +
116116
"if you need to increase the limit.",
117117
payloadSize, maxPayloadSize

src/main/java/com/rabbitmq/client/impl/NettyFrameHandlerFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,10 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
469469
int type = m.readUnsignedByte();
470470
int channel = m.readUnsignedShort();
471471
int payloadSize = m.readInt();
472-
if (payloadSize >= maxPayloadSize) {
473-
throw new IllegalStateException(
472+
if (payloadSize < 0 || payloadSize >= maxPayloadSize) {
473+
throw new MalformedFrameException(
474474
format(
475-
"Frame body is too large (%d), maximum configured size is %d. "
475+
"Frame body size is invalid (%d), maximum configured size is %d. "
476476
+ "See ConnectionFactory#setMaxInboundMessageBodySize "
477477
+ "if you need to increase the limit.",
478478
payloadSize, maxPayloadSize));

0 commit comments

Comments
 (0)