blob: de16f5d50795dc858f35309813ebb0caf7249ae8 [file] [log] [blame]
Filip Vargaeb601242018-10-31 07:58:05 +01001diff --git a/scapy/contrib/cdp.py b/scapy/contrib/cdp.py
2index c8b7f106..7b1ff64d 100644
3--- a/scapy/contrib/cdp.py
4+++ b/scapy/contrib/cdp.py
5@@ -102,7 +102,8 @@ def _CDPGuessPayloadClass(p, **kargs):
6 class CDPMsgGeneric(Packet):
7 name = "CDP Generic Message"
8 fields_desc = [ XShortEnumField("type", None, _cdp_tlv_types),
9- FieldLenField("len", None, "val", "!H"),
10+ FieldLenField("len", None, "val", "!H",
11+ adjust=lambda pkt, x: x + 4),
12 StrLenField("val", "", length_from=lambda x:x.len - 4) ]
13
14
Ole Troan2a884db2019-10-23 11:24:23 +020015@@ -178,5 +179,6 @@ class CDPMsgAddr(CDPMsgGeneric):
Filip Vargaeb601242018-10-31 07:58:05 +010016 class CDPMsgPortID(CDPMsgGeneric):
17 name = "Port ID"
18 fields_desc = [ XShortEnumField("type", 0x0003, _cdp_tlv_types),
19- FieldLenField("len", None, "iface", "!H"),
20+ FieldLenField("len", None, "iface", "!H",
21+ adjust=lambda pkt, x: x + 4),
22 StrLenField("iface", "Port 1", length_from=lambda x:x.len - 4) ]
Ole Troan2a884db2019-10-23 11:24:23 +020023@@ -319,7 +319,7 @@ class _CDPChecksum:
24 This padding is only used for checksum computation. The original
25 packet should not be altered."""
26 if len(pkt) % 2:
27- last_chr = pkt[-1]
28+ last_chr = pkt[len(pkt)-1:]
29 if last_chr <= b'\x80':
30 return pkt[:-1] + b'\x00' + last_chr
31 else: