tabish121 commented on code in PR #2167:
URL: https://github.com/apache/activemq/pull/2167#discussion_r3507942159
##########
activemq-amqp/src/main/java/org/apache/activemq/transport/amqp/AmqpFrameParser.java:
##########
@@ -86,6 +86,8 @@ private void validateFrameSize(int frameSize) throws
IOException {
if (frameSize > maxFrameSize) {
throw IOExceptionSupport.createFrameSizeException(frameSize,
maxFrameSize);
+ } else if (frameSize <= 0) {
Review Comment:
This could be improved a bit as the lower limit on frame size is actually 8
bytes and the type of the size value is an unsigned int so you should actually
be using `Integer.compareUnsigned()` if you wanted to be precise on what went
wrong.
This is an example from a Qpid proton frame decoder:
```
private void validateFrameSize() throws FrameDecodingException {
if (Integer.compareUnsigned(frameSize, 8) < 0) {
throw new FrameDecodingException(String.format(
"specified frame size %d smaller than minimum frame
header size 8", frameSize));
}
if (Integer.toUnsignedLong(frameSize) >
configuration.getInboundMaxFrameSize()) {
throw new FrameDecodingException(String.format(
"specified frame size %s larger than maximum frame size
%d",
Integer.toUnsignedString(frameSize),
configuration.getInboundMaxFrameSize()));
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact