fixed PublishDecoder min remaining length
@@ -32,6 +32,8 @@ import static org.mqttbee.mqtt5.message.publish.Mqtt5PublishInternal.*;
@Singleton
public class Mqtt5PublishDecoder implements Mqtt5MessageDecoder {
+ private static final int MIN_REMAINING_LENGTH = 3;
+
@Override
@Nullable
public Mqtt5PublishInternal decode(final int flags, @NotNull final Channel channel, @NotNull final ByteBuf in) {
@@ -48,6 +50,11 @@ public class Mqtt5PublishDecoder implements Mqtt5MessageDecoder {
return null;
}
+ if (in.readableBytes() < MIN_REMAINING_LENGTH) {
+ disconnectRemainingLengthTooShort(channel, in);
+ return null;
+ }
+
final byte[] topicBinary = Mqtt5DataTypes.decodeBinaryData(in);
Mqtt5Topic topic = null;
if (topicBinary.length != 0) {
