From 493a0c3cc07ca423d9ce6b47de5709b0b350f1de Mon Sep 17 00:00:00 2001 From: Shudong Zhou <shudongzhou@gmail.com> Date: Thu, 30 May 2013 16:23:10 -0700 Subject: [PATCH] Throw exception when TCP header length is < 20 --- src/main/java/net/floodlightcontroller/packet/TCP.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/floodlightcontroller/packet/TCP.java b/src/main/java/net/floodlightcontroller/packet/TCP.java index c282c5d8a..5c2f02946 100644 --- a/src/main/java/net/floodlightcontroller/packet/TCP.java +++ b/src/main/java/net/floodlightcontroller/packet/TCP.java @@ -266,6 +266,9 @@ public class TCP extends BasePacket { this.acknowledge = bb.getInt(); this.flags = bb.getShort(); this.dataOffset = (byte) ((this.flags >> 12) & 0xf); + if (this.dataOffset < 5) { + throw new RuntimeException("Invalid tcp header length < 20"); + } this.flags = (short) (this.flags & 0x1ff); this.windowSize = bb.getShort(); this.checksum = bb.getShort(); @@ -282,7 +285,7 @@ public class TCP extends BasePacket { this.options = null; } } - + this.payload = new Data(); int remLength = bb.limit()-bb.position(); this.payload = payload.deserialize(data, bb.position(), remLength); -- GitLab