Issue 137 in dpkt: lldp parser should stop at end tlv

16 views
Skip to first unread message

dp...@googlecode.com

unread,
Feb 13, 2015, 6:13:29 PM2/13/15
to dp...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 137 by cha...@google.com: lldp parser should stop at end tlv
https://code.google.com/p/dpkt/issues/detail?id=137

What steps will reproduce the problem?
1. create an ethernet packet that is padded for min length
2. add only required tlv to lldp pdu
0000: 01 80 c2 00 00 0e b6 0b bc fd ca 93 88 cc 02 02 07 01 04 02 07 33
06 02 12 34 10 0c 05 01
0030: c0 00 00 02 03 03 00 00 00 00 00 00 00 00
make sure to pad the ethernet packet with zero for min length

3. lldp.unpack(pkt[14:]). unpack pass the ethernet header, not specifying
the end of lldp packet
(need to parse it to get that length...)

What is the expected output? What do you see instead?
in LLDP.unpack(), we should get an unpacked PDU
instead we get an error, invalid length, due to parsing continuing pass
the TLV_END

proposed fix lldp.py, class LLDP

def unpack(self, buf):
super(LLDP, self).unpack(buf)
self.tlvs = []

while buf:
tlv_type = LLDPBasicTLV.get_type(buf)
basic_tlv = self._tlv_parsers[tlv_type](buf)
self.tlvs.append(basic_tlv)
buf = buf[len(basic_tlv):]
+ if (basic_tlv.tlv_type == LLDP_TLV_END):
+ buf = ''
+ return
+

Found another problem while parsing the management address for the same
packet,
the offset for the interface / oid is of by 1.

class ManagementAddress
def unpack(self, buf):
super(ManagementAddress, self).unpack(buf)
(self.addr_len, self.addr_subtype) = struct.unpack(
self.ADDR_STR, self.data[:self.ADDR_SIZE])
if not self._addr_len_valid():
raise dpkt.UnpackError('invalid addr len')
- offset = self.ADDR_SIZE + self.addr_len
+ offset = self.ADDR_SIZE + self.addr_len -1
self._addr = self.data[self.ADDR_SIZE:offset]




--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

dp...@googlecode.com

unread,
Feb 20, 2015, 5:44:03 AM2/20/15
to dp...@googlegroups.com

Comment #1 on issue 137 by twistedj...@gmail.com: lldp parser should stop
FUCKING JUNKIE
Reply all
Reply to author
Forward
0 new messages