From 4297106c093cd24459ecc67675a47192d67ed2fe Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 23 Oct 2018 22:06:33 -0400 Subject: Do not let the server load chunks from newer versions If the server attempts to load a chunk generated by a newer version of the game, immediately stop the server to prevent data corruption. You can override this functionality at your own peril. --- ...the-server-load-chunks-from-newer-version.patch | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch diff --git a/Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch b/Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch new file mode 100644 index 0000000000..c11afbeaff --- /dev/null +++ b/Spigot-Server-Patches/0366-Do-not-let-the-server-load-chunks-from-newer-version.patch @@ -0,0 +1,40 @@ +From 652ddff89bc697d79803e1fc33b767bc5af0c1a8 Mon Sep 17 00:00:00 2001 +From: Zach Brown +Date: Tue, 23 Oct 2018 22:03:37 -0400 +Subject: [PATCH] Do not let the server load chunks from newer versions + +If the server attempts to load a chunk generated by a newer version of +the game, immediately stop the server to prevent data corruption. + +You can override this functionality at your own peril. + +diff --git a/src/main/java/net/minecraft/server/ChunkRegionLoader.java b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +index bad287fca..e6906effb 100644 +--- a/src/main/java/net/minecraft/server/ChunkRegionLoader.java ++++ b/src/main/java/net/minecraft/server/ChunkRegionLoader.java +@@ -90,8 +90,22 @@ public class ChunkRegionLoader implements IChunkLoader, IAsyncChunkSaver { + return nbttagcompound != null ? true : RegionFileCache.chunkExists(this.d, i, j); + } + ++ // Paper start ++ private static final int CURRENT_DATA_VERSION = 1343; // Paper ++ private static final boolean JUST_CORRUPT_IT = Boolean.valueOf("Paper.ignoreWorldDataVersion"); ++ // Paper end ++ + @Nullable + protected Object[] a(World world, int i, int j, NBTTagCompound nbttagcompound) { // CraftBukkit - return Chunk -> Object[] ++ // Paper start - Do NOT attempt to load chunks saved with newer versions ++ if (nbttagcompound.hasKeyOfType("DataVersion", 3)) { ++ int dataVersion = nbttagcompound.getInt("DataVersion"); ++ if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) { ++ new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace(); ++ System.exit(1); ++ } ++ } ++ // Paper end + if (!nbttagcompound.hasKeyOfType("Level", 10)) { + ChunkRegionLoader.a.error("Chunk file at {},{} is missing level data, skipping", Integer.valueOf(i), Integer.valueOf(j)); + return null; +-- +2.19.1 + -- cgit v1.2.3