packet lib: stop tlv parsing when finding LLDP_TLV_END

There may be padding at the end of payload.
So the assumption that there is no payload after LLDP_TLV_END
is not correct.

Reported-by: Q Lady <holynn.q@gmail.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Isaku Yamahata 2013-06-24 11:06:21 +09:00 committed by FUJITA Tomonori
parent 694c8330a5
commit 23e6b8fcb8

View File

@ -137,9 +137,10 @@ class lldp(packet_base.PacketBase):
tlv = cls._tlv_parsers[tlv_type](buf)
tlvs.append(tlv)
offset = LLDP_TLV_SIZE + tlv.len
if tlv.tlv_type == LLDP_TLV_END:
break
buf = buf[offset:]
assert (len(buf) > 0 and tlv.tlv_type != LLDP_TLV_END) or \
(len(buf) == 0 and tlv.tlv_type == LLDP_TLV_END)
assert len(buf) > 0
lldp_pkt = cls(tlvs)