aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZach Brown <[email protected]>2017-05-13 20:26:19 -0500
committerZach Brown <[email protected]>2017-05-13 20:26:19 -0500
commita76ba5c11814244dfda4fa759bb7b44688f42a80 (patch)
treeb0607ee67a72227aa4e992452ddeaace492a373a
parent2103c75247529cad3c9765120b9c285a3e65793c (diff)
downloadPaper-a76ba5c11814244dfda4fa759bb7b44688f42a80.tar.gz
Paper-a76ba5c11814244dfda4fa759bb7b44688f42a80.zip
Add system property to disable book size limits
-rw-r--r--Spigot-Server-Patches/0212-Add-system-property-to-disable-book-size-limits.patch61
1 files changed, 61 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0212-Add-system-property-to-disable-book-size-limits.patch b/Spigot-Server-Patches/0212-Add-system-property-to-disable-book-size-limits.patch
new file mode 100644
index 0000000000..3b58f3fb18
--- /dev/null
+++ b/Spigot-Server-Patches/0212-Add-system-property-to-disable-book-size-limits.patch
@@ -0,0 +1,61 @@
+From f31346cefbd60ba0b705ca9021bda1e7e944164f Mon Sep 17 00:00:00 2001
+From: Zach Brown <[email protected]>
+Date: Sat, 13 May 2017 20:11:21 -0500
+Subject: [PATCH] Add system property to disable book size limits
+
+If anyone comes in with a watchdog crash related to books after this patch
+you will not only be publicly shamed but also made an example of.
+
+Disables the security limits on books entirely, allowing plugins AND players
+to make books with as much data as they want. Do not use this without
+limiting incoming data from packets in some other way.
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+index 78065e134..4e04134c0 100644
+--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java
+@@ -37,6 +37,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
+ static final int MAX_PAGES = 50;
+ static final int MAX_PAGE_LENGTH = 256;
+ static final int MAX_TITLE_LENGTH = 32;
++ private static final boolean OVERRIDE_CHECKS = Boolean.getBoolean("disable.book-limits"); // Paper - Add override
+
+ protected String title;
+ protected String author;
+@@ -193,7 +194,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
+ if (title == null) {
+ this.title = null;
+ return true;
+- } else if (title.length() > MAX_TITLE_LENGTH) {
++ } else if (title.length() > MAX_TITLE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
+ return false;
+ }
+
+@@ -229,7 +230,7 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
+ throw new IllegalArgumentException("Invalid page number " + page + "/" + pages.size());
+ }
+
+- String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH ? text.substring(0, MAX_PAGE_LENGTH) : text;
++ String newText = text == null ? "" : text.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS ? text.substring(0, MAX_PAGE_LENGTH) : text;
+ pages.set(page - 1, CraftChatMessage.fromString(newText, true)[0]);
+ }
+
+@@ -241,13 +242,13 @@ public class CraftMetaBook extends CraftMetaItem implements BookMeta {
+
+ public void addPage(final String... pages) {
+ for (String page : pages) {
+- if (this.pages.size() >= MAX_PAGES) {
++ if (this.pages.size() >= MAX_PAGES && !OVERRIDE_CHECKS) {
+ return;
+ }
+
+ if (page == null) {
+ page = "";
+- } else if (page.length() > MAX_PAGE_LENGTH) {
++ } else if (page.length() > MAX_PAGE_LENGTH && !OVERRIDE_CHECKS) { // Paper - Add override
+ page = page.substring(0, MAX_PAGE_LENGTH);
+ }
+
+--
+2.13.0.windows.1
+