From 81f21d28642e50e9fae1f7feadbb2882e7820f40 Mon Sep 17 00:00:00 2001 From: Benjamin James Harrison-Sims Date: Sun, 14 Apr 2013 21:19:57 +0500 Subject: [PATCH] Prevent handshake spam from invalid names. diff --git a/src/main/java/net/minecraft/server/Packet2Handshake.java b/src/main/java/net/minecraft/server/Packet2Handshake.java index 343af93..26de0b5 100644 --- a/src/main/java/net/minecraft/server/Packet2Handshake.java +++ b/src/main/java/net/minecraft/server/Packet2Handshake.java @@ -14,11 +14,13 @@ public class Packet2Handshake extends Packet { public Packet2Handshake() {} + public static final java.util.regex.Pattern validName = java.util.regex.Pattern.compile("^[a-zA-Z0-9_-]{2,16}$"); public void a(DataInputStream datainputstream) throws IOException { // CraftBukkit - throws IOException this.a = datainputstream.readByte(); this.b = a(datainputstream, 16); this.c = a(datainputstream, 255); this.d = datainputstream.readInt(); + if(!validName.matcher(this.b).matches()) throw new IOException("Invalid name!"); // Spigot } public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException -- 1.8.1.2