From 472c20e5e9b6c63367dc8df871ad22185c716327 Mon Sep 17 00:00:00 2001 From: sirjonasxx <36828922+sirjonasxx@users.noreply.github.com> Date: Fri, 12 Oct 2018 17:59:12 +0200 Subject: [PATCH] critical bug in HPacket.structureEquals() --- src/main/protocol/HPacket.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/protocol/HPacket.java b/src/main/protocol/HPacket.java index 24a5fda..2d3e4c3 100644 --- a/src/main/protocol/HPacket.java +++ b/src/main/protocol/HPacket.java @@ -197,7 +197,7 @@ public class HPacket implements StringifyAble { String s = split[i]; if (s.equals("s")) { - if (readUshort(readIndex) + 2 + readIndex > getBytesLength()) return false; + if (readIndex + 2 > getBytesLength() || readUshort(readIndex) + 2 + readIndex > getBytesLength()) return false; readString(); } else if (s.equals("i")) { @@ -840,5 +840,9 @@ public class HPacket implements StringifyAble { } public static void main(String[] args) { + HPacket packet = new HPacket("{l}{u:1442}"); + + System.out.println(packet.structureEquals("s,b")); + } } \ No newline at end of file