diff --git a/src/de/steamwar/bungeecore/listeners/mods/Forge.java b/src/de/steamwar/bungeecore/listeners/mods/Forge.java index 2a6a8cab..e94d21dc 100644 --- a/src/de/steamwar/bungeecore/listeners/mods/Forge.java +++ b/src/de/steamwar/bungeecore/listeners/mods/Forge.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.listeners.mods; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.sql.Mod; +import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.event.LoginEvent; import net.md_5.bungee.api.event.ProxyPingEvent; @@ -103,15 +104,24 @@ public class Forge extends BasicListener { //for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29 Utils.VarInt channelLength = Utils.readVarInt(data, 0); int pos = channelLength.length; - assert new String(data, pos, channelLength.value).equals("fml:handshake"); + if(!new String(data, pos, channelLength.value).equals("fml:handshake")) { + event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x00)")); + return; + } Utils.VarInt length = Utils.readVarInt(data, pos); pos += length.length; - assert channelLength.length + channelLength.value + length.length + length.value == data.length; + if(channelLength.length + channelLength.value + length.length + length.value != data.length) { + event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x01)")); + return; + } Utils.VarInt packetId = Utils.readVarInt(data, pos); pos += packetId.length; - assert packetId.value == 2; + if(packetId.value != 2) { + event.getConnection().disconnect(TextComponent.fromLegacyText("Invalid forge registry response (0x02)")); + return; + } Utils.VarInt modCount = Utils.readVarInt(data, pos); pos += modCount.length;