mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Fix invalid channel names sent from the server causing the network thread to error. (#8902)
This commit is contained in:
1 parent
094200e687
commit
f9d0daa91c
1 file changed
+9
-1
@@ -5,14 +5,17 @@
|
||||
|
||||
package net.minecraftforge.network;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.util.Attribute;
|
||||
import net.minecraft.ResourceLocationException;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@@ -24,6 +27,7 @@ import java.util.function.Supplier;
|
||||
|
||||
public class MCRegisterPacketHandler
|
||||
{
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
public static final MCRegisterPacketHandler INSTANCE = new MCRegisterPacketHandler();
|
||||
|
||||
public static class ChannelList {
|
||||
@@ -62,7 +66,11 @@ public class MCRegisterPacketHandler
|
||||
for (int cur = 0; cur < all.length; cur++) {
|
||||
if (all[cur] == '\0') {
|
||||
String s = new String(all, last, cur - last, StandardCharsets.UTF_8);
|
||||
rl.add(new ResourceLocation(s));
|
||||
try {
|
||||
rl.add(new ResourceLocation(s));
|
||||
} catch (ResourceLocationException ex) {
|
||||
LOGGER.warn("Invalid channel name received: {}. Ignoring", s);
|
||||
}
|
||||
last = cur + 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user