resolved: roll back partial DNS zone publication
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 623a4c97b9
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user