Commit ee967b18 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Sanity check packets before trying to decode

parent 78c10874
......@@ -156,15 +156,16 @@ class Packet:
self.destination = buf.read(6)
self.source = buf.read(6)
self.eth_type = buf.read(2)
flags = buf.decode_byte()
self.flags = flags & flag_MASK
self.kind = flags & kind_MASK
self.channel = buf.decode_packed32()
self.cookie = buf.decode_uint32()
self.index = buf.decode_uint32()
self.frag_num = buf.decode_packed32()
frag_length = buf.decode_packed32()
self.data = buf.read(frag_length)
if self.eth_type == 'EX':
flags = buf.decode_byte()
self.flags = flags & flag_MASK
self.kind = flags & kind_MASK
self.channel = buf.decode_packed32()
self.cookie = buf.decode_uint32()
self.index = buf.decode_uint32()
self.frag_num = buf.decode_packed32()
frag_length = buf.decode_packed32()
self.data = buf.read(frag_length)
def join(self, other):
if self.destination != other.destination:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment