From a6986f6837e8d50b433185bec1c0dc8c4db621c6 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 21 Feb 2025 00:56:47 -0800 Subject: [PATCH] remove 'target' parameter from dns_name_concatenate() the target buffer passed to dns_name_concatenate() was never used (except for one place in dig, where it wasn't actually needed, and has already been removed in a prior commit). we can safely remove the parameter. --- bin/dig/dighost.c | 2 +- bin/dnssec/dnssec-signzone.c | 2 +- lib/dns/adb.c | 3 +-- lib/dns/client.c | 2 +- lib/dns/dnssec.c | 2 +- lib/dns/include/dns/name.h | 25 +++++++++---------------- lib/dns/name.c | 23 +++++++++-------------- lib/dns/nsec.c | 3 +-- lib/dns/qpzone.c | 2 +- lib/dns/rdata/generic/mx_15.c | 2 +- lib/dns/rdata/in_1/srv_33.c | 2 +- lib/dns/resolver.c | 3 +-- lib/dns/rpz.c | 2 +- lib/dns/rrl.c | 2 +- lib/dns/sdlz.c | 4 ++-- lib/dns/ssu.c | 2 +- lib/dns/tkey.c | 3 +-- lib/dns/validator.c | 3 +-- lib/dns/zone.c | 2 +- lib/ns/query.c | 22 ++++++++++------------ 20 files changed, 46 insertions(+), 65 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 91aaa0f42e..4dbae24a6b 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2277,7 +2277,7 @@ setup_lookup(dig_lookup_t *lookup) { if (!dns_name_isabsolute(name)) { result = dns_name_concatenate( name, lookup->oname, - lookup->name, NULL); + lookup->name); } else { dns_name_copy(name, lookup->name); } diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index cfb8f5141e..7ef9236dff 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -959,7 +959,7 @@ addnowildcardhash(hashlist_t *l, wild = dns_fixedname_initname(&fixed); - result = dns_name_concatenate(dns_wildcardname, name, wild, NULL); + result = dns_name_concatenate(dns_wildcardname, name, wild); if (result == ISC_R_NOSPACE) { return; } diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 88313cbce6..5682090d30 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -875,8 +875,7 @@ set_target(dns_adb_t *adb, const dns_name_t *name, const dns_name_t *fname, prefix = dns_fixedname_initname(&fixed1); new_target = dns_fixedname_initname(&fixed2); dns_name_split(name, nlabels, prefix, NULL); - result = dns_name_concatenate(prefix, &dname.dname, new_target, - NULL); + result = dns_name_concatenate(prefix, &dname.dname, new_target); dns_rdata_freestruct(&dname); if (result != ISC_R_SUCCESS) { return result; diff --git a/lib/dns/client.c b/lib/dns/client.c index 350a8a06ad..0fb9d9012e 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -652,7 +652,7 @@ client_resfind(resctx_t *rctx, dns_fetchresponse_t *resp) { prefix = dns_fixedname_initname(&fixed); dns_name_split(name, nlabels, prefix, NULL); tresult = dns_name_concatenate(prefix, &dname.dname, - name, NULL); + name); dns_rdata_freestruct(&dname); if (tresult == ISC_R_SUCCESS) { want_restart = true; diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index cda1115ded..2220dbb233 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -592,7 +592,7 @@ cleanup_struct: RUNTIME_CHECK(dns_name_concatenate( dns_wildcardname, dns_fixedname_name(&fnewname), - wild, NULL) == ISC_R_SUCCESS); + wild) == ISC_R_SUCCESS); } inc_stat(dns_dnssecstats_wildcard); ret = DNS_R_FROMWILDCARD; diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 2760e5bf89..320e36b2ea 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -302,9 +302,10 @@ dns_name_setbuffer(dns_name_t *name, isc_buffer_t *buffer) { * Dedicate a buffer for use with 'name'. * * Notes: - * \li Specification of a target buffer in dns_name_fromwire(), - * dns_name_fromtext(), and dns_name_concatenate() is optional if - * 'name' has a dedicated buffer. + * \li Specification of a target buffer in dns_name_fromwire() and + * dns_name_fromtext() is optional if 'name' has a dedicated buffer. + * The target name in dns_name_concatenate() must have a dedicated + * buffer. * * \li The caller must not write to buffer until the name has been * invalidated or is otherwise known not to be in use. @@ -959,9 +960,11 @@ dns_name_downcase(const dns_name_t *source, dns_name_t *name); isc_result_t dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix, - dns_name_t *name, isc_buffer_t *target); + dns_name_t *name); /*%< - * Concatenate 'prefix' and 'suffix'. + * Concatenate 'prefix' and 'suffix' and place the result in 'name'. + * (Note that 'name' may be the same as 'prefix', in which case + * 'suffix' will be appended to it.) * * Requires: * @@ -969,20 +972,10 @@ dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix, * *\li 'suffix' is a valid name or NULL. * - *\li 'name' is a valid name or NULL. - * - *\li 'target' is a valid buffer or 'target' is NULL and 'name' has - * a dedicated buffer. + *\li 'name' is a valid name with a dedicated buffer. * *\li If 'prefix' is absolute, 'suffix' must be NULL or the empty name. * - * Ensures: - * - *\li On success, - * If 'target' is not NULL and 'name' is not NULL, then 'name' - * is attached to it. - * The used space in target is updated. - * * Returns: *\li #ISC_R_SUCCESS *\li #ISC_R_NOSPACE diff --git a/lib/dns/name.c b/lib/dns/name.c index 138848937d..193c25e310 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1511,13 +1511,14 @@ dns_name_towire(const dns_name_t *name, dns_compress_t *cctx, isc_result_t dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix, - dns_name_t *name, isc_buffer_t *target) { - unsigned char *ndata; + dns_name_t *name) { + unsigned char *ndata = NULL; unsigned int nrem, prefix_length, length; bool copy_prefix = true; bool copy_suffix = true; bool absolute = false; dns_name_t tmp_name; + isc_buffer_t *target = NULL; /* * Concatenate 'prefix' and 'suffix'. @@ -1525,10 +1526,9 @@ dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix, REQUIRE(prefix == NULL || DNS_NAME_VALID(prefix)); REQUIRE(suffix == NULL || DNS_NAME_VALID(suffix)); - REQUIRE(name == NULL || DNS_NAME_VALID(name)); - REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || - (target == NULL && name != NULL && - ISC_BUFFER_VALID(name->buffer))); + REQUIRE(DNS_NAME_VALID(name) && ISC_BUFFER_VALID(name->buffer)); + REQUIRE(DNS_NAME_BINDABLE(name)); + if (prefix == NULL || prefix->length == 0) { copy_prefix = false; } @@ -1543,13 +1543,9 @@ dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix, dns_name_init(&tmp_name); name = &tmp_name; } - if (target == NULL) { - INSIST(name->buffer != NULL); - target = name->buffer; - isc_buffer_clear(name->buffer); - } - REQUIRE(DNS_NAME_BINDABLE(name)); + target = name->buffer; + isc_buffer_clear(target); /* * Set up. @@ -1583,8 +1579,7 @@ dns_name_concatenate(const dns_name_t *prefix, const dns_name_t *suffix, } /* - * If 'prefix' and 'name' are the same object, and the object has - * a dedicated buffer, and we're using it, then we don't have to + * If 'prefix' and 'name' are the same object, we don't have to * copy anything. */ if (copy_prefix && (prefix != name || prefix->buffer != target)) { diff --git a/lib/dns/nsec.c b/lib/dns/nsec.c index 23ed781164..7fa26758d8 100644 --- a/lib/dns/nsec.c +++ b/lib/dns/nsec.c @@ -483,8 +483,7 @@ dns_nsec_noexistnodata(dns_rdatatype_t type, const dns_name_t *name, dns_name_getlabelsequence(&nsec.next, labels - nlabels, nlabels, &common); } - result = dns_name_concatenate(dns_wildcardname, &common, wild, - NULL); + result = dns_name_concatenate(dns_wildcardname, &common, wild); if (result != ISC_R_SUCCESS) { dns_rdata_freestruct(&nsec); (*logit)(arg, ISC_LOG_DEBUG(3), diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 8851542592..766d25fe8a 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -2960,7 +2960,7 @@ find_wildcard(qpz_search_t *search, qpznode_t **nodep, * Construct the wildcard name for this level. */ result = dns_name_concatenate(dns_wildcardname, - &node->name, wname, NULL); + &node->name, wname); if (result != ISC_R_SUCCESS) { break; } diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index 20510dda98..afa40e6309 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -290,7 +290,7 @@ additionaldata_mx(ARGS_ADDLDATA) { dns_fixedname_init(&fixed); result = dns_name_concatenate(&port25, &name, - dns_fixedname_name(&fixed), NULL); + dns_fixedname_name(&fixed)); if (result != ISC_R_SUCCESS) { return ISC_R_SUCCESS; } diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index d488b94193..0b8f34b53b 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -341,7 +341,7 @@ additionaldata_in_srv(ARGS_ADDLDATA) { } result = dns_name_concatenate(dns_fixedname_name(&fixed), &name, - dns_fixedname_name(&fixed), NULL); + dns_fixedname_name(&fixed)); if (result != ISC_R_SUCCESS) { return ISC_R_SUCCESS; } diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index e2601548fe..73d4815163 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -6929,8 +6929,7 @@ is_answertarget_allowed(fetchctx_t *fctx, dns_name_t *qname, dns_name_t *rname, tname = dns_fixedname_initname(&fixed); nlabels = dns_name_countlabels(rname); dns_name_split(qname, nlabels, &prefix, NULL); - result = dns_name_concatenate(&prefix, &dname.dname, tname, - NULL); + result = dns_name_concatenate(&prefix, &dname.dname, tname); if (result == DNS_R_NAMETOOLONG) { SET_IF_NOT_NULL(chainingp, true); return true; diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index 130d833f3f..24a95af3d5 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -1071,7 +1071,7 @@ name2data(dns_rpz_zone_t *rpz, dns_rpz_type_t rpz_type, n -= dns_name_countlabels(&rpz->nsdname); } dns_name_getlabelsequence(src_name, prefix_len, n, &tmp_name); - (void)dns_name_concatenate(&tmp_name, dns_rootname, trig_name, NULL); + (void)dns_name_concatenate(&tmp_name, dns_rootname, trig_name); } #ifndef HAVE_BUILTIN_CLZ diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index e9fa6171a3..ede8966cc8 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -432,7 +432,7 @@ make_key(const dns_rrl_t *rrl, dns_rrl_key_t *key, */ wild = dns_fixedname_initname(&fixed); result = dns_name_concatenate(dns_wildcardname, origin, - wild, NULL); + wild); if (result != ISC_R_SUCCESS) { /* * Fallback to use the zone's origin name diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 29cf564c6a..c65da7cd5e 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -549,8 +549,8 @@ getnodedata(dns_db_t *db, const dns_name_t *name, bool create, fname = dns_fixedname_name(&fixed); dns_name_getlabelsequence( name, i + 1, dlabels - i - 1, fname); - result = dns_name_concatenate( - dns_wildcardname, fname, fname, NULL); + result = dns_name_concatenate(dns_wildcardname, + fname, fname); if (result != ISC_R_SUCCESS) { MAYBE_UNLOCK(sdlz->dlzimp); return result; diff --git a/lib/dns/ssu.c b/lib/dns/ssu.c index f289204100..0649307400 100644 --- a/lib/dns/ssu.c +++ b/lib/dns/ssu.c @@ -631,7 +631,7 @@ dns_ssutable_checkrules(dns_ssutable_t *table, const dns_name_t *signer, case dns_ssumatchtype_selfwild: wildcard = dns_fixedname_initname(&fixed); result = dns_name_concatenate(dns_wildcardname, signer, - wildcard, NULL); + wildcard); if (result != ISC_R_SUCCESS) { if (logit) { isc_log_write( diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index c34d8f8f3f..377cdb9047 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -475,8 +475,7 @@ dns_tkey_processquery(dns_message_t *msg, dns_tkeyctx_t *tctx, RETERR(isc_hex_totext(&r, 2, "", &b)); RETERR(dns_name_fromtext(keyname, &b, NULL, 0, NULL)); } - RETERR(dns_name_concatenate(keyname, dns_rootname, keyname, - NULL)); + RETERR(dns_name_concatenate(keyname, dns_rootname, keyname)); result = dns_tsigkey_find(&tsigkey, keyname, NULL, ring); if (result == ISC_R_SUCCESS) { diff --git a/lib/dns/validator.c b/lib/dns/validator.c index fd73251976..806d20da8e 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -2610,8 +2610,7 @@ findnsec3proofs(dns_validator_t *val) { { val->attributes |= VALATTR_FOUNDCLOSEST; result = dns_name_concatenate(dns_wildcardname, closest, - dns_fixedname_name(&val->wild), - NULL); + dns_fixedname_name(&val->wild)); RUNTIME_CHECK(result == ISC_R_SUCCESS); } else { val->attributes &= ~VALATTR_FOUNDNOQNAME; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 98690078b2..bc02181527 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -4881,7 +4881,7 @@ check_reportchannel(dns_zone_t *zone, dns_db_t *db) { * Otherwise, we need a '*._er' wildcard with a TXT rdataset. */ name = dns_fixedname_initname(&fixed); - CHECK(dns_name_concatenate(&er, &zone->origin, name, NULL)); + CHECK(dns_name_concatenate(&er, &zone->origin, name)); CHECK(dns_db_findnode(db, name, false, &node)); dns_db_currentversion(db, &version); diff --git a/lib/ns/query.c b/lib/ns/query.c index b9d33f1142..8382b8ede3 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -3181,7 +3181,7 @@ rpz_get_p_name(ns_client_t *client, dns_name_t *p_name, dns_rpz_zone_t *rpz, for (;;) { dns_name_getlabelsequence(trig_name, first, labels - first - 1, &prefix); - result = dns_name_concatenate(&prefix, suffix, p_name, NULL); + result = dns_name_concatenate(&prefix, suffix, p_name); if (result == ISC_R_SUCCESS) { break; } @@ -4900,9 +4900,8 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, dns_name_init(&prefix); dns_name_getlabelsequence(client->query.qname, 0, labels - 1, &prefix); - result = dns_name_concatenate(&prefix, - client->view->redirectzone, - redirectname, NULL); + result = dns_name_concatenate( + &prefix, client->view->redirectzone, redirectname); if (result != ISC_R_SUCCESS) { return ISC_R_NOTFOUND; } @@ -4980,7 +4979,7 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, /* * Make the name absolute. */ - result = dns_name_concatenate(found, dns_rootname, found, NULL); + result = dns_name_concatenate(found, dns_rootname, found); RUNTIME_CHECK(result == ISC_R_SUCCESS); dns_name_copy(found, name); @@ -7269,7 +7268,7 @@ query_rpzcname(query_ctx_t *qctx, dns_name_t *cname) { dns_fixedname_name(&suffix)); result = dns_name_concatenate(dns_fixedname_name(&prefix), dns_fixedname_name(&suffix), - qctx->fname, NULL); + qctx->fname); if (result == DNS_R_NAMETOOLONG) { client->message->rcode = dns_rcode_yxdomain; } else if (result != ISC_R_SUCCESS) { @@ -9271,8 +9270,8 @@ query_addnxrrsetnsec(query_ctx_t *qctx) { dns_name_split(qctx->fname, sig.labels + 1, NULL, fname); /* This will succeed, since we've stripped labels. */ - RUNTIME_CHECK(dns_name_concatenate(dns_wildcardname, fname, fname, - NULL) == ISC_R_SUCCESS); + RUNTIME_CHECK(dns_name_concatenate(dns_wildcardname, fname, fname) == + ISC_R_SUCCESS); query_addrrset(qctx, &fname, &qctx->rdataset, &qctx->sigrdataset, dbuf, DNS_SECTION_AUTHORITY); } @@ -10385,7 +10384,7 @@ query_dname(query_ctx_t *qctx) { INSIST(qctx->fname == NULL); qctx->dbuf = ns_client_getnamebuf(qctx->client); qctx->fname = ns_client_newname(qctx->client, qctx->dbuf, &b); - result = dns_name_concatenate(prefix, tname, qctx->fname, NULL); + result = dns_name_concatenate(prefix, tname, qctx->fname); dns_message_puttempname(qctx->client->message, &tname); /* @@ -11190,8 +11189,7 @@ again: /* * Add the no wildcard proof. */ - result = dns_name_concatenate(dns_wildcardname, cname, wname, - NULL); + result = dns_name_concatenate(dns_wildcardname, cname, wname); if (result != ISC_R_SUCCESS) { goto cleanup; } @@ -11232,7 +11230,7 @@ again: dns_name_split(name, nlabels, NULL, wname); } result = dns_name_concatenate(dns_wildcardname, wname, - wname, NULL); + wname); if (result == ISC_R_SUCCESS) { have_wname = true; }