]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
resolved: roll back partial DNS zone publication
authorLuca Boccassi <luca.boccassi@gmail.com>
Mon, 13 Jul 2026 13:56:34 +0000 (14:56 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 14 Jul 2026 09:09:31 +0000 (10:09 +0100)
dns_zone_link_item() inserts a new item into the by-key hashmap before
publishing it by name. If the second hashmap insertion fails, _cleanup_
frees the item while by-key retains a dangling key and value.

Follow-up for 623a4c97b9175f95c4b1c6fc34e36c56f1e4ddbf

src/resolve/resolved-dns-zone.c

index c0053429589acff5c6a0fdb13922910069543ab0..48dce9d7429bd067b9c37ea6d5f65f578ae45fbd 100644 (file)
@@ -161,8 +161,15 @@ static int dns_zone_link_item(DnsZone *z, DnsZoneItem *i) {
                 assert_se(hashmap_replace(z->by_name, dns_resource_key_name(first->rr->key), first) >= 0);
         } else {
                 r = hashmap_put(z->by_name, dns_resource_key_name(i->rr->key), i);
-                if (r < 0)
+                if (r < 0) {
+                        first = hashmap_get(z->by_key, i->rr->key);
+                        LIST_REMOVE(by_key, first, i);
+                        if (first)
+                                assert_se(hashmap_replace(z->by_key, first->rr->key, first) >= 0);
+                        else
+                                hashmap_remove(z->by_key, i->rr->key);
                         return r;
+                }
         }
 
         return 0;