]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
resolve_chaining() should not go into an infinite loop if the qtype is
authorBob Halley <halley@dnspython.org>
Mon, 21 Dec 2020 15:11:30 +0000 (07:11 -0800)
committerBob Halley <halley@dnspython.org>
Mon, 21 Dec 2020 15:11:30 +0000 (07:11 -0800)
CNAME and there is no answer [Issue #610].

dns/message.py
tests/test_message.py

index 9824e700d5eb27860d4229bb796649c717642ae5..5c35dbc737da9b9b67a7a4411a2b3baa4bf05c59 100644 (file)
@@ -776,6 +776,9 @@ class QueryMessage(Message):
                     except KeyError:
                         # Exit the chaining loop
                         break
+                else:
+                    # Exit the chaining loop
+                    break
         if count >= MAX_CHAIN:
             raise ChainTooLong
         if self.rcode() == dns.rcode.NXDOMAIN and rrset is not None:
index 8ebcd0545145414e0f23d825f584b469985c5cbc..ec96458430e75fd62e05a7187aca4ded2a78bfc4 100644 (file)
@@ -550,6 +550,20 @@ class MessageTestCase(unittest.TestCase):
         with self.assertRaises(dns.exception.FormError):
             r.resolve_chaining()
 
+    def test_resolve_chaining_no_infinite_loop(self):
+        r = dns.message.from_text('''id 1
+flags QR
+;QUESTION
+www.example. IN CNAME
+;AUTHORITY
+example. 300 IN SOA . . 1 2 3 4 5
+''')
+        # passing is actuall not going into an infinite loop in this call
+        (qname, min_ttl, rrset) = r.resolve_chaining()
+        self.assertEqual(qname, dns.name.from_text('www.example.'))
+        self.assertEqual(min_ttl, 5)
+        self.assertIsNone(rrset)
+
     def test_bad_text_questions(self):
         with self.assertRaises(dns.exception.SyntaxError):
             dns.message.from_text('''id 1