2015-04-16 16:38:35 +00:00
|
|
|
From 0a7fd3a0aff060a3332b562618f35b7b2fbec834 Mon Sep 17 00:00:00 2001
|
2014-07-27 19:14:24 +00:00
|
|
|
From: md_5 <git@md-5.net>
|
|
|
|
Date: Sun, 27 Jul 2014 20:46:04 +1000
|
|
|
|
Subject: [PATCH] Apply NBTReadLimiter to more things.
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java b/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
|
2015-02-28 11:36:22 +00:00
|
|
|
index 2a04b86..b2d5254 100644
|
2014-07-27 19:14:24 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
|
2015-02-28 11:36:22 +00:00
|
|
|
@@ -44,6 +44,12 @@ public class NBTCompressedStreamTools {
|
|
|
|
}
|
2014-07-30 08:35:19 +00:00
|
|
|
|
2015-02-28 11:36:22 +00:00
|
|
|
public static NBTTagCompound a(DataInput datainput, NBTReadLimiter nbtreadlimiter) throws IOException {
|
2014-11-28 01:17:45 +00:00
|
|
|
+ // Spigot start
|
|
|
|
+ if ( datainput instanceof io.netty.buffer.ByteBufInputStream )
|
|
|
|
+ {
|
|
|
|
+ datainput = new DataInputStream(new org.spigotmc.LimitStream((InputStream) datainput, nbtreadlimiter));
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
NBTBase nbtbase = a(datainput, 0, nbtreadlimiter);
|
2014-07-30 08:35:19 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
if (nbtbase instanceof NBTTagCompound) {
|
2015-04-16 16:38:35 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/NBTTagList.java b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
|
|
index e34c774..6d91deb 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/NBTTagList.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NBTTagList.java
|
|
|
|
@@ -45,6 +45,7 @@ public class NBTTagList extends NBTBase {
|
|
|
|
|
|
|
|
for (int k = 0; k < j; ++k) {
|
|
|
|
NBTBase nbtbase = NBTBase.createTag(this.type);
|
|
|
|
+ nbtreadlimiter.a(8); // Spigot
|
|
|
|
|
|
|
|
nbtbase.load(datainput, i + 1, nbtreadlimiter);
|
|
|
|
this.list.add(nbtbase);
|
2014-07-27 19:14:24 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/LimitStream.java b/src/main/java/org/spigotmc/LimitStream.java
|
|
|
|
new file mode 100644
|
2015-04-16 16:38:35 +00:00
|
|
|
index 0000000..8c32e8b
|
2014-07-27 19:14:24 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/LimitStream.java
|
|
|
|
@@ -0,0 +1,39 @@
|
|
|
|
+package org.spigotmc;
|
|
|
|
+
|
|
|
|
+import java.io.FilterInputStream;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import net.minecraft.server.NBTReadLimiter;
|
|
|
|
+
|
|
|
|
+public class LimitStream extends FilterInputStream
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ private final NBTReadLimiter limit;
|
|
|
|
+
|
|
|
|
+ public LimitStream(InputStream is, NBTReadLimiter limit)
|
|
|
|
+ {
|
|
|
|
+ super( is );
|
|
|
|
+ this.limit = limit;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int read() throws IOException
|
|
|
|
+ {
|
2015-04-16 16:38:35 +00:00
|
|
|
+ limit.a( 8 );
|
2014-07-27 19:14:24 +00:00
|
|
|
+ return super.read();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int read(byte[] b) throws IOException
|
|
|
|
+ {
|
2015-04-16 16:38:35 +00:00
|
|
|
+ limit.a( b.length * 8 );
|
2014-07-27 19:14:24 +00:00
|
|
|
+ return super.read( b );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public int read(byte[] b, int off, int len) throws IOException
|
|
|
|
+ {
|
2015-04-16 16:38:35 +00:00
|
|
|
+ limit.a( len * 8 );
|
2014-07-27 19:14:24 +00:00
|
|
|
+ return super.read( b, off, len );
|
|
|
|
+ }
|
|
|
|
+}
|
2014-07-30 08:35:19 +00:00
|
|
|
--
|
2014-11-28 01:17:45 +00:00
|
|
|
2.1.0
|
2014-07-30 08:35:19 +00:00
|
|
|
|