]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Update zone.py
authortmerila <tuomas@merila.org>
Wed, 3 Apr 2019 11:12:23 +0000 (14:12 +0300)
committerGitHub <noreply@github.com>
Wed, 3 Apr 2019 11:12:23 +0000 (14:12 +0300)
Instead of moving the entire TTL parsing past the rdata handling (causing the RR to be parsed on the wrong way), returned the parsing to its original location, and only moved the final failure code past the rdata handling.

dns/zone.py

index e80a3ca2fb62971e147b85e0908f348d0dcd97f0..2b9157b956e3f8f2c5fd1c1f6db1e652e1edd94d 100644 (file)
@@ -659,6 +659,21 @@ class _MasterReader(object):
         if not token.is_identifier():
             raise dns.exception.SyntaxError
 
+        # TTL
+        ttl = None
+        try:
+            ttl = dns.ttl.from_text(token.value)
+            self.last_ttl = ttl
+            self.last_ttl_known = True
+            token = self.tok.get()
+            if not token.is_identifier():
+                raise dns.exception.SyntaxError
+        except dns.ttl.BadTTL:
+            if self.default_ttl_known:
+                ttl = self.default_ttl
+            else:
+                ttl = self.last_ttl
+                
         # Class
         try:
             rdclass = dns.rdataclass.from_text(token.value)
@@ -705,21 +720,15 @@ class _MasterReader(object):
             self.default_ttl = rd.minimum
             self.default_ttl_known = True
 
-        # TTL
-        try:
-            ttl = dns.ttl.from_text(token.value)
-            self.last_ttl = ttl
-            self.last_ttl_known = True
-            token = self.tok.get()
-            if not token.is_identifier():
-                raise dns.exception.SyntaxError
-        except dns.ttl.BadTTL:
+        # TTL check
+        if ttl is None:
             if not (self.last_ttl_known or self.default_ttl_known):
                 raise dns.exception.SyntaxError("Missing default TTL value")
-            if self.default_ttl_known:
-                ttl = self.default_ttl
             else:
-                ttl = self.last_ttl
+                if self.default_ttl_known:
+                    ttl = self.default_ttl
+                else:
+                    ttl = self.last_ttl
             
         rd.choose_relativity(self.zone.origin, self.relativize)
         covers = rd.covers()