2013-04-14 16:32:19 +00:00
|
|
|
From 2869840ad478538331bca1e3440b41dd554cf429 Mon Sep 17 00:00:00 2001
|
2013-04-14 02:09:29 +00:00
|
|
|
From: Benjamin James Harrison-Sims <tehrainbowguy@gmail.com>
|
2013-04-14 16:32:19 +00:00
|
|
|
Date: Sun, 14 Apr 2013 21:19:57 +0500
|
2013-04-14 02:09:29 +00:00
|
|
|
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
|
2013-04-14 02:25:35 +00:00
|
|
|
index 343af93..aa6609b 100644
|
2013-04-14 02:09:29 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Packet2Handshake.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Packet2Handshake.java
|
2013-04-14 02:25:35 +00:00
|
|
|
@@ -1,5 +1,7 @@
|
|
|
|
package net.minecraft.server;
|
|
|
|
|
|
|
|
+import org.bukkit.craftbukkit.Spigot;
|
|
|
|
+
|
|
|
|
import java.io.DataInputStream;
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
|
|
|
|
@@ -19,6 +21,7 @@ public class Packet2Handshake extends Packet {
|
2013-04-14 02:09:29 +00:00
|
|
|
this.b = a(datainputstream, 16);
|
|
|
|
this.c = a(datainputstream, 255);
|
|
|
|
this.d = datainputstream.readInt();
|
2013-04-14 02:25:35 +00:00
|
|
|
+ if(!Spigot.validName.matcher(this.b).matches()) throw new IOException("Invalid name!"); // Spigot
|
2013-04-14 02:09:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void a(DataOutputStream dataoutputstream) throws IOException { // CraftBukkit - throws IOException
|
2013-04-14 02:25:35 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Spigot.java b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
2013-04-14 16:32:19 +00:00
|
|
|
index 504bd8b..ff28a99 100644
|
2013-04-14 02:25:35 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Spigot.java
|
|
|
|
@@ -9,6 +9,8 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
+
|
|
|
|
import net.minecraft.server.EntityPlayer;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.spigotmc.Metrics;
|
|
|
|
@@ -25,6 +27,7 @@ public class Spigot {
|
|
|
|
private static Metrics metrics;
|
|
|
|
public static List<String> bungeeIPs;
|
|
|
|
public static int textureResolution = 16;
|
2013-04-14 16:32:19 +00:00
|
|
|
+ public static final Pattern validName = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
|
2013-04-14 02:25:35 +00:00
|
|
|
|
|
|
|
public static void initialize(CraftServer server, SimpleCommandMap commandMap, YamlConfiguration configuration) {
|
|
|
|
commandMap.register("bukkit", new org.bukkit.craftbukkit.command.TicksPerSecondCommand("tps"));
|
2013-04-14 02:09:29 +00:00
|
|
|
--
|
2013-04-14 16:32:19 +00:00
|
|
|
1.7.11.msysgit.0
|
2013-04-14 02:09:29 +00:00
|
|
|
|