chiark / gitweb /
resolve: reject empty TXT records
authorStanisław Pitucha <viraptor@gmail.com>
Tue, 18 Nov 2014 03:52:13 +0000 (14:52 +1100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 27 Nov 2014 16:07:43 +0000 (11:07 -0500)
TXT records should have at least one character, so enforce this.

Before 0f84a72 parser SIGSEGV'd on ->txt.strings being NULL, but
even if this is fixed we should reject invalid TXT records.

src/resolve/resolved-dns-packet.c

index c587a56..a9bd8b1 100644 (file)
@@ -1114,6 +1114,13 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
         case DNS_TYPE_TXT: {
                 char *s;
 
+                /* RFC 1035 says that TXT must be at least one
+                   string. Reject empty records. */
+                if (!rdlength) {
+                        r = -EBADMSG;
+                        goto fail;
+                }
+
                 while (p->rindex < offset + rdlength) {
                         r = dns_packet_read_string(p, &s, NULL);
                         if (r < 0)