]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix incorrect cleanup after an allocation failure for
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jun 2026 08:49:50 +0000 (10:49 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 16 Jun 2026 08:49:50 +0000 (10:49 +0200)
  a delegation point. Thanks to Qifan Zhang, Palo Alto
  Networks, for the report.

doc/Changelog
iterator/iter_delegpt.c

index e9894a09d562fc2d7720e3bf9632c0b060b0d8b0..2672f3319637212733f53b5d35deede60de9a0c8 100644 (file)
@@ -44,6 +44,9 @@
        - Fix for neater solution to clear log thread id after
          worker init failure. Thanks to Qifan Zhang, Palo Alto
          Networks, for the report.
+       - Fix incorrect cleanup after an allocation failure for
+         a delegation point. Thanks to Qifan Zhang, Palo Alto
+         Networks, for the report.
 
 15 June 2026: Wouter
        - Fix to add `max-transfer-size` and `max-transfer-time` that
index 5b609c960dd28d3423e6102a1f08ec80a055774c..7f3bef943e3fc0b651076a1c53cb717b36d1e9c1 100644 (file)
@@ -664,8 +664,6 @@ int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, uint8_t lame,
                free(ns);
                return 0;
        }
-       ns->next = dp->nslist;
-       dp->nslist = ns;
        ns->cache_lookup_count = 0;
        ns->resolved = 0;
        ns->got4 = 0;
@@ -684,6 +682,8 @@ int delegpt_add_ns_mlc(struct delegpt* dp, uint8_t* name, uint8_t lame,
        } else {
                ns->tls_auth_name = NULL;
        }
+       ns->next = dp->nslist;
+       dp->nslist = ns;
        return 1;
 }
 
@@ -709,11 +709,7 @@ int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr,
        a = (struct delegpt_addr*)malloc(sizeof(struct delegpt_addr));
        if(!a)
                return 0;
-       a->next_target = dp->target_list;
-       dp->target_list = a;
        a->next_result = 0;
-       a->next_usable = dp->usable_list;
-       dp->usable_list = a;
        memcpy(&a->addr, addr, addrlen);
        a->addrlen = addrlen;
        a->attempts = 0;
@@ -729,6 +725,10 @@ int delegpt_add_addr_mlc(struct delegpt* dp, struct sockaddr_storage* addr,
        } else {
                a->tls_auth_name = NULL;
        }
+       a->next_target = dp->target_list;
+       dp->target_list = a;
+       a->next_usable = dp->usable_list;
+       dp->usable_list = a;
        return 1;
 }