2021-06-09 03:25:38 +02:00
|
|
|
From 92d4715a7044c29ab63cfdf9b65c145be7860873 Mon Sep 17 00:00:00 2001
|
2020-12-16 11:14:44 +01:00
|
|
|
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
|
2021-06-09 01:33:36 +02:00
|
|
|
index 01d35f41..ec07ae6f 100644
|
2020-12-16 11:14:44 +01:00
|
|
|
--- a/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
|
|
|
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/MinecraftDecoder.java
|
2021-02-26 02:46:21 +01:00
|
|
|
@@ -38,6 +38,19 @@ public class MinecraftDecoder extends MessageToMessageDecoder<ByteBuf>
|
2020-12-16 11:14:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2020-12-16 11:44:19 +01:00
|
|
|
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
|
2021-06-09 01:33:36 +02:00
|
|
|
index 270545f2..3bbc1510 100644
|
2020-12-16 11:44:19 +01:00
|
|
|
--- a/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
|
|
|
+++ b/proxy/src/main/java/net/md_5/bungee/netty/HandlerBoss.java
|
2021-06-09 01:33:36 +02:00
|
|
|
@@ -78,6 +78,11 @@ public class HandlerBoss extends ChannelInboundHandlerAdapter
|
2020-12-16 11:44:19 +01:00
|
|
|
@Override
|
|
|
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
|
|
|
|
{
|
|
|
|
+ // FlameCord - Return if channel isn't active
|
|
|
|
+ if (!ctx.channel().isActive()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if ( msg instanceof HAProxyMessage )
|
|
|
|
{
|
|
|
|
HAProxyMessage proxy = (HAProxyMessage) msg;
|
2020-12-16 11:14:44 +01:00
|
|
|
--
|
2021-06-09 01:33:36 +02:00
|
|
|
2.31.1.windows.1
|
2020-12-16 11:14:44 +01:00
|
|
|
|