mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
packet lib: don't crash with corrupted lldp packet
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Tested-by: Benjamin Eggerstedt <benjamin.eggerstedt@gmail.com>
This commit is contained in:
parent
f0ab847f64
commit
1f2b24e834
@ -124,7 +124,7 @@ class lldp(packet_base.PacketBase):
|
||||
self.tlvs[-1].tlv_type == LLDP_TLV_END)
|
||||
|
||||
@classmethod
|
||||
def parser(cls, buf):
|
||||
def _parser(cls, buf):
|
||||
tlvs = []
|
||||
|
||||
while buf:
|
||||
@ -144,6 +144,13 @@ class lldp(packet_base.PacketBase):
|
||||
|
||||
return lldp_pkt, None, buf
|
||||
|
||||
@classmethod
|
||||
def parser(cls, buf):
|
||||
try:
|
||||
return cls._parser(buf)
|
||||
except:
|
||||
return None, None, buf
|
||||
|
||||
def serialize(self, payload, prev):
|
||||
data = bytearray()
|
||||
for tlv in self.tlvs:
|
||||
|
||||
@ -286,6 +286,10 @@ class TestLLDPOptionalTLV(unittest.TestCase):
|
||||
# End
|
||||
eq_(tlvs[16].tlv_type, lldp.LLDP_TLV_END)
|
||||
|
||||
def test_parse_corrupted(self):
|
||||
buf = self.data
|
||||
pkt = packet.Packet(buf[:128])
|
||||
|
||||
def test_serialize(self):
|
||||
pkt = packet.Packet()
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user