Catch stalling on corrupted map data / NBT arrays.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2014-01-20 13:44:07 +11:00
parent 1f67404bb9
commit bfc73d87f0
2 changed files with 16 additions and 0 deletions

View file

@ -5,3 +5,11 @@
package net.minecraft.nbt;
import java.io.DataInput;
@@ -24,6 +25,7 @@
private static byte[] readAccounted(DataInput input, NbtAccounter tracker) throws IOException {
tracker.accountBytes(24L);
int i = input.readInt();
+ com.google.common.base.Preconditions.checkArgument( i < 1 << 24); // Spigot
tracker.accountBytes(1L, (long) i);
byte[] abyte = new byte[i];

View file

@ -5,3 +5,11 @@
package net.minecraft.nbt;
import java.io.DataInput;
@@ -24,6 +25,7 @@
private static int[] readAccounted(DataInput input, NbtAccounter tracker) throws IOException {
tracker.accountBytes(24L);
int i = input.readInt();
+ com.google.common.base.Preconditions.checkArgument( i < 1 << 24); // Spigot
tracker.accountBytes(4L, (long) i);
int[] aint = new int[i];