]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove dns__tsig_algallocated()
authorEvan Hunt <each@isc.org>
Wed, 12 Apr 2023 07:17:30 +0000 (00:17 -0700)
committerEvan Hunt <each@isc.org>
Wed, 14 Jun 2023 08:14:38 +0000 (08:14 +0000)
this function was no longer needed, because the algorithm name is no
longer copied into the tsigkey object by dns_tsigkey_createfromkey();
it's always just a pointer to a statically defined name.

lib/dns/tsig.c
lib/dns/tsig_p.h
tests/dns/tsig_test.c

index 4ae37e764a1c00dfa677fc83d757d59a3e216f46..c75caff365b57e2bf51fcf988c451929511c187e 100644 (file)
@@ -378,27 +378,6 @@ dns__tsig_algfromname(const dns_name_t *algorithm) {
        return (DST_ALG_UNKNOWN);
 }
 
-/*
- * Test whether the passed algorithm is NOT a pointer to one of the
- * pre-defined known algorithms (and therefore one that has been
- * dynamically allocated).
- *
- * This will return an incorrect result if passed a dynamically allocated
- * dns_name_t that happens to match one of the pre-defined names.
- */
-bool
-dns__tsig_algallocated(const dns_name_t *algorithm) {
-       int i;
-       int n = sizeof(known_algs) / sizeof(*known_algs);
-       for (i = 0; i < n; ++i) {
-               const dns_name_t *name = known_algs[i].name;
-               if (algorithm == name) {
-                       return (false);
-               }
-       }
-       return (true);
-}
-
 static isc_result_t
 restore_key(dns_tsigkeyring_t *ring, isc_stdtime_t now, FILE *fp) {
        dst_key_t *dstkey = NULL;
@@ -604,11 +583,6 @@ destroy_tsigkey(dns_tsigkey_t *key) {
 
        key->magic = 0;
        dns_name_free(&key->name, key->mctx);
-       if (dns__tsig_algallocated(key->algorithm)) {
-               dns_name_t *name = UNCONST(key->algorithm);
-               dns_name_free(name, key->mctx);
-               isc_mem_put(key->mctx, name, sizeof(dns_name_t));
-       }
        if (key->key != NULL) {
                dst_key_free(&key->key);
        }
index 80e73237367565a74738bf3ddc8cefe28f3e233d..42316a06088d341c7c3a6947d5fbdb4f2f56f85e 100644 (file)
@@ -32,7 +32,5 @@ bool
 dns__tsig_algvalid(unsigned int alg);
 dst_algorithm_t
 dns__tsig_algfromname(const dns_name_t *algorithm);
-bool
-dns__tsig_algallocated(const dns_name_t *algorithm);
 
 ISC_LANG_ENDDECLS
index fdc9ed3989a88e86c9f0eafce75d084591dd49c4..88632b921ae22b510d46658909e86608e526eb82 100644 (file)
@@ -485,29 +485,9 @@ ISC_RUN_TEST_IMPL(algvalid) {
        assert_false(dns__tsig_algvalid(DST_ALG_GSSAPI));
 }
 
-/* Tests the dns__tsig_algallocated function */
-ISC_RUN_TEST_IMPL(algallocated) {
-       UNUSED(state);
-
-       /* test the standard algorithms */
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACMD5_NAME));
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA1_NAME));
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA224_NAME));
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA256_NAME));
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA384_NAME));
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA512_NAME));
-
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA512_NAME));
-       assert_false(dns__tsig_algallocated(DNS_TSIG_HMACSHA512_NAME));
-
-       /* try another name that isn't a standard algorithm name */
-       assert_true(dns__tsig_algallocated(dns_rootname));
-}
-
 ISC_TEST_LIST_START
 ISC_TEST_ENTRY_CUSTOM(tsig_tcp, setup_test, teardown_test)
 ISC_TEST_ENTRY(algvalid)
-ISC_TEST_ENTRY(algallocated)
 ISC_TEST_LIST_END
 
 ISC_TEST_MAIN