diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-11-27 16:08:46 +0100 |
---|---|---|
committer | David Herrmann <dh.herrmann@gmail.com> | 2014-11-27 16:10:44 +0100 |
commit | 0f84a72e3c0f58d71cff2121e6df1611eaf9c9ea (patch) | |
tree | defc60dc5073ffe1c27cb2c33f6a73d2c3420619 /src/resolve/resolved-dns-rr.c | |
parent | 342f3005f57fe293d3b43148f8c900f2cbc6f7f7 (diff) |
resolve: fix NULL deref on strv comparison
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 <viraptor@gmail.com> for reporting this!
Diffstat (limited to 'src/resolve/resolved-dns-rr.c')
-rw-r--r-- | src/resolve/resolved-dns-rr.c | 10 |
1 files changed, 2 insertions, 8 deletions
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; |