Paper/CraftBukkit-Patches/0166-Apply-NBTReadLimiter-to-more-things.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

67 lines
2.1 KiB
Diff

From 2058c5a4ca7b63a86f429fbf8fecd75ade24464a Mon Sep 17 00:00:00 2001
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
index 20fe0f1..6defdf5 100644
--- a/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
+++ b/src/main/java/net/minecraft/server/NBTCompressedStreamTools.java
@@ -46,7 +46,7 @@ public class NBTCompressedStreamTools {
public static NBTTagCompound a(byte[] abyte, NBTReadLimiter nbtreadlimiter) {
try {
- DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new ByteArrayInputStream(abyte))));
+ DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new org.spigotmc.LimitStream(new GZIPInputStream(new ByteArrayInputStream(abyte)), nbtreadlimiter))); // Spigot
NBTTagCompound nbttagcompound;
diff --git a/src/main/java/org/spigotmc/LimitStream.java b/src/main/java/org/spigotmc/LimitStream.java
new file mode 100644
index 0000000..dcc0548
--- /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
+ {
+ limit.a( 1 );
+ return super.read();
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException
+ {
+ limit.a( b.length );
+ return super.read( b );
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException
+ {
+ limit.a( len );
+ return super.read( b, off, len );
+ }
+}
--
1.9.1