From 23e6b8fcb88bcd767c9b413dd489e40eac7c595d Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Mon, 24 Jun 2013 11:06:21 +0900 Subject: [PATCH] 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 Signed-off-by: Isaku Yamahata Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/lldp.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py index f343359d..c0f16a46 100644 --- a/ryu/lib/packet/lldp.py +++ b/ryu/lib/packet/lldp.py @@ -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)