diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-05-06 17:43:25 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-05-07 08:14:41 +0200 |
commit | 71aee23dba7faeef68e7232f444626267a6c90d7 (patch) | |
tree | c6d54d025ec03350790826065a2d087bee8da351 /src/resolve/resolved-dns-trust-anchor.c | |
parent | ordered-set: introduce ordered_set_reserve() (diff) | |
download | systemd-71aee23dba7faeef68e7232f444626267a6c90d7.tar.xz systemd-71aee23dba7faeef68e7232f444626267a6c90d7.zip |
resolve: manage DnsAnswerItem with OrderedSet
Previously, we manage DnsAnswerItem by an array and Set,
The array was used for the order of the items, and the set is used to
dedup items.
Let's use OrderedSet, then we can simplify the logic.
This fixes dns_answer_remove_by_key() and dns_answer_remove_by_rr()
which makes the set in a broken state.
Diffstat (limited to 'src/resolve/resolved-dns-trust-anchor.c')
-rw-r--r-- | src/resolve/resolved-dns-trust-anchor.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/resolve/resolved-dns-trust-anchor.c b/src/resolve/resolved-dns-trust-anchor.c index 4a6c06d13d..9dbe861070 100644 --- a/src/resolve/resolved-dns-trust-anchor.c +++ b/src/resolve/resolved-dns-trust-anchor.c @@ -599,6 +599,7 @@ static int dns_trust_anchor_revoked_put(DnsTrustAnchor *d, DnsResourceRecord *rr static int dns_trust_anchor_remove_revoked(DnsTrustAnchor *d, DnsResourceRecord *rr) { _cleanup_(dns_answer_unrefp) DnsAnswer *new_answer = NULL; DnsAnswer *old_answer; + DnsAnswerItem *item; int r; /* Remember that this is a revoked trust anchor RR */ @@ -631,11 +632,12 @@ static int dns_trust_anchor_remove_revoked(DnsTrustAnchor *d, DnsResourceRecord return 1; } - r = hashmap_replace(d->positive_by_key, new_answer->items[0].rr->key, new_answer); + item = ordered_set_first(new_answer->items); + r = hashmap_replace(d->positive_by_key, item->rr->key, new_answer); if (r < 0) return r; - new_answer = NULL; + TAKE_PTR(new_answer); dns_answer_unref(old_answer); return 1; } |