]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolve: drop recursion in TXT field handling
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 10 Dec 2022 01:21:41 +0000 (10:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 10 Dec 2022 01:32:09 +0000 (10:32 +0900)
Fixes #25683.

src/resolve/resolved-dns-rr.c

index a4ba6bdc6d0c83d23fad3a481a50da3c502a8bd4..5f890f950938a2e8685ef7e8d0e7ea3d74513952 100644 (file)
@@ -1768,36 +1768,30 @@ int dns_resource_record_get_cname_target(DnsResourceKey *key, DnsResourceRecord
         return 0;
 }
 
-DnsTxtItem *dns_txt_item_free_all(DnsTxtItem *i) {
-        DnsTxtItem *n;
-
-        if (!i)
-                return NULL;
-
-        n = i->items_next;
+DnsTxtItem *dns_txt_item_free_all(DnsTxtItem *first) {
+        LIST_FOREACH(items, i, first)
+                free(i);
 
-        free(i);
-        return dns_txt_item_free_all(n);
+        return NULL;
 }
 
 bool dns_txt_item_equal(DnsTxtItem *a, DnsTxtItem *b) {
+        DnsTxtItem *bb = b;
 
         if (a == b)
                 return true;
 
-        if (!a != !b)
-                return false;
-
-        if (!a)
-                return true;
+        LIST_FOREACH(items, aa, a) {
+                if (!bb)
+                        return false;
 
-        if (a->length != b->length)
-                return false;
+                if (memcmp_nn(aa->data, aa->length, bb->data, bb->length) != 0)
+                        return false;
 
-        if (memcmp(a->data, b->data, a->length) != 0)
-                return false;
+                bb = bb->items_next;
+        }
 
-        return dns_txt_item_equal(a->items_next, b->items_next);
+        return !bb;
 }
 
 DnsTxtItem *dns_txt_item_copy(DnsTxtItem *first) {