]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Raise NoPreviousName if a text message tries to refer to a previous name but there...
authorBob Halley <halley@dnspython.org>
Tue, 28 Jul 2020 16:47:39 +0000 (09:47 -0700)
committerBob Halley <halley@dnspython.org>
Tue, 28 Jul 2020 16:47:39 +0000 (09:47 -0700)
dns/message.py

index 59e2692bd7d4a08ac3f42cdb36200387637dab7e..52e3819f38cbe9fc92e9753488caea85bceffd7f 100644 (file)
@@ -92,6 +92,9 @@ class ChainTooLong(dns.exception.DNSException):
 class AnswerForNXDOMAIN(dns.exception.DNSException):
     """The rcode is NXDOMAIN but an answer was found."""
 
+class NoPreviousName(dns.exception.SyntaxError):
+    """No previous name was known."""
+
 
 class MessageSection(dns.enum.IntEnum):
     """Message sections"""
@@ -1129,6 +1132,8 @@ class _TextReader:
                                               self.relativize,
                                               self.relativize_to)
         name = self.last_name
+        if name is None:
+            raise NoPreviousName
         token = self.tok.get()
         if not token.is_identifier():
             raise dns.exception.SyntaxError
@@ -1163,6 +1168,8 @@ class _TextReader:
                                               self.relativize,
                                               self.relativize_to)
         name = self.last_name
+        if name is None:
+            raise NoPreviousName
         token = self.tok.get()
         if not token.is_identifier():
             raise dns.exception.SyntaxError
@@ -1193,6 +1200,8 @@ class _TextReader:
         token = self.tok.get()
         if empty and not token.is_eol_or_eof():
             raise dns.exception.SyntaxError
+        if not empty and token.is_eol_or_eof():
+            raise dns.exception.UnexpectedEnd
         if not token.is_eol_or_eof():
             self.tok.unget(token)
             rd = dns.rdata.from_text(rdclass, rdtype, self.tok,