2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

Suppress duplicate digest types

When adding CDS digest types to the kasp structure, check for
duplicates.
This commit is contained in:
Matthijs Mekking
2023-02-13 16:11:46 +01:00
parent f2c0c4ed4e
commit 28cde5cac2

View File

@@ -529,14 +529,27 @@ dns_kasp_digests(dns_kasp_t *kasp) {
void
dns_kasp_adddigest(dns_kasp_t *kasp, dns_dsdigest_t alg) {
dns_kasp_digest_t *digest;
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
if (dst_ds_digest_supported(alg)) {
dns_kasp_digest_t *digest = isc_mem_get(kasp->mctx,
sizeof(*digest));
digest->digest = alg;
ISC_LINK_INIT(digest, link);
ISC_LIST_APPEND(kasp->digests, digest, link);
/* Suppress unsupported algorithms */
if (!dst_ds_digest_supported(alg)) {
return;
}
/* Suppress duplicates */
for (dns_kasp_digest_t *d = ISC_LIST_HEAD(kasp->digests); d != NULL;
d = ISC_LIST_NEXT(d, link))
{
if (d->digest == alg) {
return;
}
}
digest = isc_mem_get(kasp->mctx, sizeof(*digest));
digest->digest = alg;
ISC_LINK_INIT(digest, link);
ISC_LIST_APPEND(kasp->digests, digest, link);
}