Skip to content

Commit 8789985

Browse files
committed
Fix ClientSubnetv4 Calculates Address Length Incorrectly issue
1 parent ded1d73 commit 8789985

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

scapy/layers/dns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ class ClientSubnetv4(StrLenField):
546546

547547
def getfield(self, pkt, s):
548548
# type: (Packet, bytes) -> Tuple[bytes, I]
549-
sz = operator.floordiv(self.length_from(pkt), 8)
549+
sz = operator.floordiv(self.length_from(pkt) + 7, 8)
550550
sz = min(sz, operator.floordiv(self.af_length, 8))
551551
return s[sz:], self.m2i(pkt, s[:sz])
552552

test/scapy/layers/dns.uts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,3 +516,7 @@ assert p == eval(p.command())
516516
pkt = DNSQR(qname=["domain1.com", "domain2.com"], qtype="A")
517517
for i in pkt:
518518
assert i.qname in [b"domain1.com.", b"domain2.com."]
519+
520+
b = b'\x00\x08\x00\x0c\x00\x02=\x00+\xaf\xa3\xc4\xed\xeeW\xb8'
521+
p = EDNS0ClientSubnet(b)
522+
assert p.source_plen == 61 and p.address == '2baf:a3c4:edee:57b8::'

0 commit comments

Comments
 (0)