check for length before encoding varint frame

This commit is contained in:
creeper123123321 2021-02-03 21:01:17 -03:00
parent 56a1495b12
commit c7a126cf61

View File

@ -162,6 +162,7 @@ class FrameCodec : ByteToMessageCodec<ByteBuf>() {
}
override fun encode(ctx: ChannelHandlerContext, msg: ByteBuf, out: ByteBuf) {
if (msg.readableBytes() >= 2097152) throw badLength
Type.VAR_INT.writePrimitive(out, msg.readableBytes())
out.writeBytes(msg)
}