Francois Clad | d47da68 | 2018-07-09 16:33:39 +0200 | [diff] [blame] | 1 | diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py |
| 2 | index 6f9f16b..d61c621 100644 |
| 3 | --- a/scapy/layers/inet6.py |
| 4 | +++ b/scapy/layers/inet6.py |
| 5 | @@ -1089,9 +1089,9 @@ class IPv6ExtHdrSegmentRouting(_IPv6ExtHdr): |
| 6 | BitField("unused2", 0, 3), |
| 7 | ShortField("tag", 0), |
| 8 | IP6ListField("addresses", ["::1"], |
| 9 | - count_from=lambda pkt: pkt.lastentry), |
| 10 | + count_from=lambda pkt: pkt.lastentry+1), |
| 11 | PacketListField("tlv_objects", [], IPv6ExtHdrSegmentRoutingTLV, |
| 12 | - length_from=lambda pkt: 8*pkt.len - 16*pkt.lastentry) ] |
| 13 | + length_from=lambda pkt: 8*pkt.len - 16*(pkt.lastentry+1)) ] |
| 14 | |
| 15 | overload_fields = { IPv6: { "nh": 43 } } |
| 16 | |
| 17 | @@ -1119,7 +1119,10 @@ class IPv6ExtHdrSegmentRouting(_IPv6ExtHdr): |
| 18 | pkt = pkt[:3] + struct.pack("B", tmp_len) + pkt[4:] |
| 19 | |
| 20 | if self.lastentry is None: |
| 21 | - pkt = pkt[:4] + struct.pack("B", len(self.addresses)) + pkt[5:] |
| 22 | + tmp_len = len(self.addresses) |
| 23 | + if tmp_len: |
| 24 | + tmp_len -= 1 |
| 25 | + pkt = pkt[:4] + struct.pack("B", tmp_len) + pkt[5:] |
| 26 | |
| 27 | return _IPv6ExtHdr.post_build(self, pkt, pay) |
| 28 | |