From 0f84a72e3c0f58d71cff2121e6df1611eaf9c9ea Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 27 Nov 2014 16:08:46 +0100 Subject: resolve: fix NULL deref on strv comparison MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A strv might be NULL if it is empty. The txt.strings comparison doesn't take that into account. Introduce strv_equal() to provide a proper helper for this and fix resolve to use it. Thanks to Stanisław Pitucha for reporting this! --- src/resolve/resolved-dns-rr.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/resolve') diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c index fd5ecf413d..78d9e4a412 100644 --- a/src/resolve/resolved-dns-rr.c +++ b/src/resolve/resolved-dns-rr.c @@ -370,14 +370,8 @@ int dns_resource_record_equal(const DnsResourceRecord *a, const DnsResourceRecor strcaseeq(a->hinfo.os, b->hinfo.os); case DNS_TYPE_SPF: /* exactly the same as TXT */ - case DNS_TYPE_TXT: { - int i; - - for (i = 0; a->txt.strings[i] || b->txt.strings[i]; i++) - if (!streq_ptr(a->txt.strings[i], b->txt.strings[i])) - return false; - return true; - } + case DNS_TYPE_TXT: + return strv_equal(a->txt.strings, b->txt.strings); case DNS_TYPE_A: return memcmp(&a->a.in_addr, &b->a.in_addr, sizeof(struct in_addr)) == 0; -- cgit v1.2.3-54-g00ecf