PaperSpigot-Parent/CraftBukkit-Patches/0153-Safer-JSON-Loading.patch
Zach Brown 398f6983bd Update from upstream SpigotMC
Make "moved too quickly" limit configurable SpigotMC/Spigot@99a0a640e8
Undeprecate Player#updateInventory()V SpigotMC/Spigot@5c32e1cb48
Fetch complete profile for skull items, similarly to TileEntitySkull. SpigotMC/Spigot@33d758773e
Move getDouble into the Spigot Configuration patch SpigotMC/Spigot@b5dd202af1
Add missing particle to particle API SpigotMC/Spigot@273c64bbad
Log debug levels to the log file. SpigotMC/Spigot@348eae75f4
Fix PlayerItemDamageEvent (we already had this #badupstreamrelations) SpigotMC/Spigot@e207ea23cd
Move hopper patch to top for PR180 SpigotMC/Spigot@abb775108d
Don't be so spammy on Java 6 SpigotMC/Spigot@5abb82b1ca
Apply NBTReadLimiter to more things SpigotMC/Spigot@408944e9f5
2014-07-27 14:20:28 -05:00

48 lines
2.0 KiB
Diff

From 5e48f28aa1c321d023ecdd982eee5e931480c3f5 Mon Sep 17 00:00:00 2001
From: Suddenly <suddenly@suddenly.coffee>
Date: Tue, 8 Jul 2014 09:44:18 +1000
Subject: [PATCH] Safer JSON Loading
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
index 9d1cb33..3ef40f2 100644
--- a/src/main/java/net/minecraft/server/JsonList.java
+++ b/src/main/java/net/minecraft/server/JsonList.java
@@ -146,6 +146,17 @@ public class JsonList {
try {
bufferedreader = Files.newReader(this.c, Charsets.UTF_8);
collection = (Collection) this.b.fromJson(bufferedreader, f);
+ // Spigot Start
+ } catch ( java.io.FileNotFoundException ex )
+ {
+ a.info( "Unable to find file {0}, creating it.", this.c );
+ } catch ( net.minecraft.util.com.google.gson.JsonSyntaxException ex )
+ {
+ a.warn( "Unable to read file {0}, backing it up to {0}.backup and creating new copy.", this.c );
+ File backup = new File( this.c + ".backup" );
+ this.c.renameTo( backup );
+ this.c.delete();
+ // Spigot End
} finally {
IOUtils.closeQuietly(bufferedreader);
}
diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
index 9f7de3f..1ce89c4 100644
--- a/src/main/java/net/minecraft/server/UserCache.java
+++ b/src/main/java/net/minecraft/server/UserCache.java
@@ -176,6 +176,11 @@ public class UserCache {
break label81;
} catch (FileNotFoundException filenotfoundexception) {
;
+ // Spigot Start
+ } catch (net.minecraft.util.com.google.gson.JsonSyntaxException ex) {
+ JsonList.a.warn( "Usercache.json is corrupted or has bad formatting. Deleting it to prevent further issues." );
+ this.g.delete();
+ // Spigot End
} finally {
IOUtils.closeQuietly(bufferedreader);
}
--
1.9.1