aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Spigot-Server-Patches/0374-Add-Stricter-Client-Sign-limits.patch (renamed from Spigot-Server-Patches/0374-Strip-extra-Sign-data-to-from-client.patch)50
-rw-r--r--Spigot-Server-Patches/0375-Fix-sign-edit-memory-leak.patch8
2 files changed, 15 insertions, 43 deletions
diff --git a/Spigot-Server-Patches/0374-Strip-extra-Sign-data-to-from-client.patch b/Spigot-Server-Patches/0374-Add-Stricter-Client-Sign-limits.patch
index f688eb80e2..fd744ad32f 100644
--- a/Spigot-Server-Patches/0374-Strip-extra-Sign-data-to-from-client.patch
+++ b/Spigot-Server-Patches/0374-Add-Stricter-Client-Sign-limits.patch
@@ -1,7 +1,7 @@
-From 7c9f744502fe7d16b4ab37f51a5247b474609f9f Mon Sep 17 00:00:00 2001
+From 5f53285851beaedf12b297903c55b69e200b08e5 Mon Sep 17 00:00:00 2001
From: Aikar <[email protected]>
Date: Wed, 27 Feb 2019 22:18:40 -0500
-Subject: [PATCH] Strip extra Sign data to/from client
+Subject: [PATCH] Add Stricter Client Sign limits
modified clients can send abnormally large data from the client
to the server and it would get stored on the sign as sent.
@@ -15,31 +15,34 @@ sets of legacy formatting codes which should be plenty for all uses.
This does not strip any existing data from the NBT as plugins
may use this for storing data out of the rendered area.
-it only impacts data sent to and from the client.
+it only impacts data sent to and from client to extend mojangs limit.
Set -DPaper.maxSignLength=XX to change limit or -1 to disable
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index de62c3b76..cb47e54da 100644
+index de62c3b76..64520f174 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
-@@ -2227,6 +2227,11 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
+@@ -2227,6 +2227,14 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
String[] lines = new String[4];
for (int i = 0; i < astring.length; ++i) {
+ // Paper start - cap line length - modified clients can send longer data than normal
+ if (astring[i].length() > TileEntitySign.MAX_SIGN_LINE_LENGTH && TileEntitySign.MAX_SIGN_LINE_LENGTH > 0) {
-+ astring[i] = astring[i].substring(0, TileEntitySign.MAX_SIGN_LINE_LENGTH);
++ int offset = astring[i].codePoints().limit(TileEntitySign.MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
++ if (offset > astring.length) {
++ astring[i] = astring[i].substring(0, offset);
++ }
+ }
+ // Paper end
lines[i] = SharedConstants.a(astring[i]); //Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
}
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.server.getPlayer(this.player), lines);
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
-index 67bd3bcbe..6e3359362 100644
+index 67bd3bcbe..81f74c56b 100644
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
-@@ -9,15 +9,28 @@ public class TileEntitySign extends TileEntity {
+@@ -9,6 +9,7 @@ public class TileEntitySign extends TileEntity {
public boolean isEditable = true;
private EntityHuman h;
private final CommandObjectiveExecutor i = new CommandObjectiveExecutor();
@@ -47,37 +50,6 @@ index 67bd3bcbe..6e3359362 100644
public TileEntitySign() {}
-+ // Paper start
- public NBTTagCompound save(NBTTagCompound nbttagcompound) {
-+ return save(nbttagcompound, false);
-+ }
-+ public NBTTagCompound save(NBTTagCompound nbttagcompound, boolean filterLines) {
-+ // Paper end
- super.save(nbttagcompound);
-
- for (int i = 0; i < 4; ++i) {
-- String s = IChatBaseComponent.ChatSerializer.a(this.lines[i]);
-+ // Paper start
-+ String line = org.bukkit.craftbukkit.util.CraftChatMessage.fromComponent(lines[i]);
-+
-+ if (filterLines && MAX_SIGN_LINE_LENGTH > 0 && line.length() > MAX_SIGN_LINE_LENGTH) {
-+ line = line.substring(0, MAX_SIGN_LINE_LENGTH);
-+ }
-
-+ String s = IChatBaseComponent.ChatSerializer.a(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(line)[0]);
-+ // Paper end
- nbttagcompound.setString("Text" + (i + 1), s);
- }
-
-@@ -105,7 +118,7 @@ public class TileEntitySign extends TileEntity {
- }
-
- public NBTTagCompound d() {
-- return this.save(new NBTTagCompound());
-+ return this.save(new NBTTagCompound(), true); // Paper - filter lines
- }
-
- public boolean isFilteredNBT() {
--
2.21.0
diff --git a/Spigot-Server-Patches/0375-Fix-sign-edit-memory-leak.patch b/Spigot-Server-Patches/0375-Fix-sign-edit-memory-leak.patch
index 9ed718012c..3b820f5c6b 100644
--- a/Spigot-Server-Patches/0375-Fix-sign-edit-memory-leak.patch
+++ b/Spigot-Server-Patches/0375-Fix-sign-edit-memory-leak.patch
@@ -1,4 +1,4 @@
-From 48883162c25d782f0ba9e0c9f703f4dcdaa6b269 Mon Sep 17 00:00:00 2001
+From 695d16c229fc12b625aaadb92150e044fa9872f3 Mon Sep 17 00:00:00 2001
From: Aikar <[email protected]>
Date: Thu, 28 Feb 2019 00:15:28 -0500
Subject: [PATCH] Fix sign edit memory leak
@@ -6,7 +6,7 @@ Subject: [PATCH] Fix sign edit memory leak
when a player edits a sign, a reference to their Entity is never cleand up.
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
-index cb47e54da..68728d436 100644
+index 64520f174..e837a553e 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -2211,7 +2211,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
@@ -19,7 +19,7 @@ index cb47e54da..68728d436 100644
this.sendPacket(tileentity.getUpdatePacket()); // CraftBukkit
return;
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
-index 6e3359362..a320fc8e9 100644
+index 81f74c56b..4ff2c8480 100644
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
@@ -10,6 +10,7 @@ public class TileEntitySign extends TileEntity {
@@ -30,7 +30,7 @@ index 6e3359362..a320fc8e9 100644
public TileEntitySign() {}
-@@ -130,7 +131,10 @@ public class TileEntitySign extends TileEntity {
+@@ -118,7 +119,10 @@ public class TileEntitySign extends TileEntity {
}
public void a(EntityHuman entityhuman) {