[systemd-devel] [PATCH] Stop crashing on empty TXT

Stanisław Pitucha viraptor at gmail.com
Mon Nov 17 19:52:13 PST 2014


TXT records should have at least one character, so enforce this.
Previously parser SIGSEGV'd on ->txt.strings being NULL.
---
 src/resolve/resolved-dns-packet.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index e5d07b3..b02b9dd 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -1109,6 +1109,10 @@ int dns_packet_read_rr(DnsPacket *p, DnsResourceRecord **ret, size_t *start) {
         case DNS_TYPE_TXT: {
                 char *s;
 
+                if (!rdlength) {
+                        r = -EBADMSG;
+                        goto fail;
+                }
                 while (p->rindex < offset + rdlength) {
                         r = dns_packet_read_string(p, &s, NULL);
                         if (r < 0)
-- 
2.1.2



More information about the systemd-devel mailing list