From ddfd76ebdab50212affff2fe1ed4532be8fa8b3c Mon Sep 17 00:00:00 2001 From: md_5 Date: Mon, 18 May 2015 20:16:00 +1000 Subject: [PATCH] Make MinecraftDecoder a MessageToMessageDecoder --- .../main/java/net/md_5/bungee/protocol/MinecraftDecoder.java | 4 ++-- .../java/net/md_5/bungee/protocol/Varint21FrameDecoder.java | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java index b4312b6e..f9610f57 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java @@ -2,13 +2,13 @@ package net.md_5.bungee.protocol; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; +import io.netty.handler.codec.MessageToMessageDecoder; import java.util.List; import lombok.AllArgsConstructor; import lombok.Setter; @AllArgsConstructor -public class MinecraftDecoder extends ByteToMessageDecoder +public class MinecraftDecoder extends MessageToMessageDecoder { @Setter diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java index c8d75c35..0f3b5b65 100644 --- a/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Varint21FrameDecoder.java @@ -29,6 +29,10 @@ public class Varint21FrameDecoder extends ByteToMessageDecoder if ( buf[i] >= 0 ) { int length = DefinedPacket.readVarInt( Unpooled.wrappedBuffer( buf ) ); + if ( length == 0 ) + { + throw new CorruptedFrameException( "Empty Packet!" ); + } if ( in.readableBytes() < length ) {