From fa5aae8921bd7706b19eb7600c6cad4c1d708d07 Mon Sep 17 00:00:00 2001 From: tmerila Date: Wed, 3 Apr 2019 14:12:23 +0300 Subject: [PATCH] Update zone.py 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 | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/dns/zone.py b/dns/zone.py index e80a3ca2..2b9157b9 100644 --- a/dns/zone.py +++ b/dns/zone.py @@ -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() -- 2.47.3