Skip to content

Commit

Permalink
Fix DNSStrField multiple values (#4256)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpotter2 committed Feb 26, 2024
1 parent 64029e7 commit 7cb28cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scapy/layers/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ class DNSStrField(StrLenField):
It will also handle DNS decompression.
(may be StrLenField if a length_from is passed),
"""
def any2i(self, pkt, x):
if x and isinstance(x, list):
return [self.h2i(pkt, y) for y in x]
return super(DNSStrField, self).any2i(pkt, x)

def h2i(self, pkt, x):
# Setting a DNSStrField manually (h2i) means any current compression will break
Expand Down
6 changes: 6 additions & 0 deletions test/scapy/layers/dns.uts
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,9 @@ assert p == eval(p.command())

p = DNS(qd=[])
assert p == eval(p.command())

= DNS - iter through DNSStrFields

pkt = DNSQR(qname=["domain1.com", "domain2.com"], qtype="A")
for i in pkt:
assert i.qname in [b"domain1.com.", b"domain2.com."]

0 comments on commit 7cb28cf

Please sign in to comment.