summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@nominum.com>2010-10-31 13:40:00 +0000
committerBob Halley <halley@nominum.com>2010-10-31 13:40:00 +0000
commit513f7c96a0dcfad5c1347a73bd86fe09fef343b0 (patch)
treee0f7d8d255e79459879a6ee52d520daacb489d7b
parentba00be7e59185697c14b003bf27817fc6982ef4f (diff)
downloaddnspython-513f7c96a0dcfad5c1347a73bd86fe09fef343b0.tar.gz
dns.resolver.zone_for_name() would return the wrong answer sometimes if the response had a CNAME or DNAME
-rw-r--r--ChangeLog5
-rw-r--r--dns/resolver.py13
2 files changed, 13 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 45a660b..4a06474 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2010-10-31 Bob Halley <halley@dnspython.org>
+ * dns/resolver.py (zone_for_name): A query name resulting in a
+ CNAME or DNAME response to a node which had an SOA was incorrectly
+ treated as a zone origin. In these cases, we should just look
+ higher.
+
* Added zonediff.py to examples. This program compares two zones
and shows the differences either in diff-like plain text, or
HTML. Thanks to Dennis Kaarsemaker for contributing this
diff --git a/dns/resolver.py b/dns/resolver.py
index edeac01..f803eb6 100644
--- a/dns/resolver.py
+++ b/dns/resolver.py
@@ -754,9 +754,12 @@ def zone_for_name(name, rdclass=dns.rdataclass.IN, tcp=False, resolver=None):
while 1:
try:
answer = resolver.query(name, dns.rdatatype.SOA, rdclass, tcp)
- return name
+ if answer.rrset.name == name:
+ return name
+ # otherwise we were CNAMEd or DNAMEd and need to look higher
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
- try:
- name = name.parent()
- except dns.name.NoParent:
- raise NoRootSOA
+ pass
+ try:
+ name = name.parent()
+ except dns.name.NoParent:
+ raise NoRootSOA