Skip to content

Commit 960f926

Browse files
Merge pull request #1927 from rabbitmq/rabbitmq-java-client-1923
Report a malformed frame in one more case
2 parents 7f01763 + 6936879 commit 960f926

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

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

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