From 1d21f2f9252de55f0379bea9aeb8a6941c73bd4e Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sun, 16 Feb 2014 15:54:43 -0600 Subject: [PATCH] Throw Exception when generating a 30,000+ byte packet --- core/sync/AppEngPacket.java | 3 +++ core/sync/packets/PacketMEInventoryUpdate.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/core/sync/AppEngPacket.java b/core/sync/AppEngPacket.java index 4c69c952c..9e4d6e955 100644 --- a/core/sync/AppEngPacket.java +++ b/core/sync/AppEngPacket.java @@ -36,6 +36,9 @@ public abstract class AppEngPacket public FMLProxyPacket getProxy() { + if ( p.array().length > 30000 ) // 2k walking room :) + throw new IllegalArgumentException( "Sorry AE2 made a huge packet by accident!" ); + return new FMLProxyPacket( p, NetworkHandler.instance.getChannel() ); } diff --git a/core/sync/packets/PacketMEInventoryUpdate.java b/core/sync/packets/PacketMEInventoryUpdate.java index afaafa6ad..46b970e35 100644 --- a/core/sync/packets/PacketMEInventoryUpdate.java +++ b/core/sync/packets/PacketMEInventoryUpdate.java @@ -46,7 +46,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket compressFrame = null; list = new LinkedList(); - int originalBytes = stream.readableBytes(); + // int originalBytes = stream.readableBytes(); GZIPInputStream gzReader = new GZIPInputStream( new InputStream() { @@ -71,7 +71,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket } gzReader.close(); - int uncompesssedBytes = uncompesssed.readableBytes(); + // int uncompesssedBytes = uncompesssed.readableBytes(); // AELog.info( "Recv: " + originalBytes + " -> " + uncompesssedBytes ); while (uncompesssed.readableBytes() > 0)