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!
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;
return l;
}
+bool strv_equal(char **a, char **b) {
+ if (!a || !b)
+ return a == b;
+
+ for ( ; *a || *b; ++a, ++b)
+ if (!streq_ptr(*a, *b))
+ return false;
+
+ return true;
+}
+
void strv_print(char **l) {
char **s;
char **strv_remove(char **l, const char *s);
char **strv_uniq(char **l);
+bool strv_equal(char **a, char **b);
+
#define strv_contains(l, s) (!!strv_find((l), (s)))
char **strv_new(const char *x, ...) _sentinel_;