54 lines
2.2 KiB
Diff
54 lines
2.2 KiB
Diff
|
From 772e70bce0c9626cb3c724b7c30c4802f7311e63 Mon Sep 17 00:00:00 2001
|
||
|
From: foss-mc <69294560+foss-mc@users.noreply.github.com>
|
||
|
Date: Wed, 16 Dec 2020 18:10:30 +0800
|
||
|
Subject: [PATCH] Packet Checks
|
||
|
|
||
|
|
||
|
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 ac83e325..4b9b80b9 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
|
||
|
@@ -38,6 +38,19 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
||
|
}
|
||
|
|
||
|
Protocol.DirectionData prot = ( server ) ? protocol.TO_SERVER : protocol.TO_CLIENT;
|
||
|
+
|
||
|
+ // FlameCord - Check size before decoding
|
||
|
+ if (prot == protocol.TO_SERVER) {
|
||
|
+ final int readableBytes = in.readableBytes();
|
||
|
+ final int capacity = in.capacity();
|
||
|
+
|
||
|
+ if (readableBytes > 2097152) {
|
||
|
+ throw new FastDecoderException("Error decoding packet with too many readableBytes: " + readableBytes);
|
||
|
+ } else if (capacity > 2097152) {
|
||
|
+ throw new FastDecoderException("Error decoding packet with too big capacity: " + capacity);
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
ByteBuf slice = in.copy(); // Can't slice this one due to EntityMap :(
|
||
|
|
||
|
Object packetTypeInfo = null;
|
||
|
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
||
|
index f8d6becd..33605007 100644
|
||
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
||
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
||
|
@@ -78,6 +78,15 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
||
|
@Override
|
||
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
|
||
|
{
|
||
|
+ // FlameCord - Return if channel isn't active
|
||
|
+ if (!ctx.channel().isActive()) {
|
||
|
+ if (msg instanceof PacketWrapper) {
|
||
|
+ ((PacketWrapper) msg).trySingleRelease();
|
||
|
+ }
|
||
|
+
|
||
|
+ return;
|
||
|
+ }
|
||
|
+
|
||
|
if ( msg instanceof HAProxyMessage )
|
||
|
{
|
||
|
HAProxyMessage proxy = (HAProxyMessage) msg;
|
||
|
--
|
||
|
2.32.0
|
||
|
|