remove dns_name_totext2() and dns_name_toprincipal()

we can pass option flags to dns_name_totext() to get the same
results, and eliminate the extra function names.
This commit is contained in:
Evan Hunt 2023-08-15 18:52:17 -07:00
parent 62d70966f2
commit 8bda38e7d4
46 changed files with 199 additions and 181 deletions

View file

@ -274,7 +274,7 @@ emit(dns_dsdigest_t dt, bool showall, bool cds, dns_rdata_t *rdata) {
fatal("can't build record");
}
result = dns_name_totext(name, false, &nameb);
result = dns_name_totext(name, 0, &nameb);
if (result != ISC_R_SUCCESS) {
fatal("can't print name");
}

View file

@ -2672,7 +2672,7 @@ catz_addmodzone_cb(void *arg) {
name = dns_catz_entry_getname(cz->entry);
isc_buffer_init(&namebuf, nameb, DNS_NAME_FORMATSIZE);
dns_name_totext(name, true, &namebuf);
dns_name_totext(name, DNS_NAME_OMITFINALDOT, &namebuf);
isc_buffer_putuint8(&namebuf, 0);
result = dns_fwdtable_find(cz->view->fwdtable, name, &dnsforwarders);
@ -5652,7 +5652,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
CHECK(dns_name_fromstring(name, cfg_obj_asstring(obj),
dns_rootname, 0, NULL));
isc_buffer_init(&buffer, server, sizeof(server) - 1);
CHECK(dns_name_totext(name, false, &buffer));
CHECK(dns_name_totext(name, 0, &buffer));
server[isc_buffer_usedlength(&buffer)] = 0;
empty_dbtype[2] = server;
} else {
@ -5665,7 +5665,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
CHECK(dns_name_fromstring(name, cfg_obj_asstring(obj),
dns_rootname, 0, NULL));
isc_buffer_init(&buffer, contact, sizeof(contact) - 1);
CHECK(dns_name_totext(name, false, &buffer));
CHECK(dns_name_totext(name, 0, &buffer));
contact[isc_buffer_usedlength(&buffer)] = 0;
empty_dbtype[3] = contact;
} else {

View file

@ -2827,7 +2827,7 @@ lookforsoa:
size_t size;
isc_buffer_init(&buf, serverstr, sizeof(serverstr));
result = dns_name_totext(&primary, true, &buf);
result = dns_name_totext(&primary, DNS_NAME_OMITFINALDOT, &buf);
check_result(result, "dns_name_totext");
serverstr[isc_buffer_usedlength(&buf)] = 0;

View file

@ -1868,13 +1868,13 @@ dns_catz_generate_masterfilename(dns_catz_zone_t *catz, dns_catz_entry_t *entry,
isc_buffer_putstr(tbuf, catz->catzs->view->name);
isc_buffer_putstr(tbuf, "_");
result = dns_name_totext(&catz->name, true, tbuf);
result = dns_name_totext(&catz->name, DNS_NAME_OMITFINALDOT, tbuf);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
isc_buffer_putstr(tbuf, "_");
result = dns_name_totext(&entry->name, true, tbuf);
result = dns_name_totext(&entry->name, DNS_NAME_OMITFINALDOT, tbuf);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
@ -1967,7 +1967,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *catz, dns_catz_entry_t *entry,
isc_buffer_allocate(catz->catzs->mctx, &buffer, ISC_BUFFER_INCR);
isc_buffer_putstr(buffer, "zone \"");
dns_name_totext(&entry->name, true, buffer);
dns_name_totext(&entry->name, DNS_NAME_OMITFINALDOT, buffer);
isc_buffer_putstr(buffer, "\" { type secondary; primaries");
isc_buffer_putstr(buffer, " { ");
@ -2004,7 +2004,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *catz, dns_catz_entry_t *entry,
if (entry->opts.masters.keys[i] != NULL) {
isc_buffer_putstr(buffer, " key ");
result = dns_name_totext(entry->opts.masters.keys[i],
true, buffer);
DNS_NAME_OMITFINALDOT, buffer);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
@ -2013,7 +2013,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *catz, dns_catz_entry_t *entry,
if (entry->opts.masters.tlss[i] != NULL) {
isc_buffer_putstr(buffer, " tls ");
result = dns_name_totext(entry->opts.masters.tlss[i],
true, buffer);
DNS_NAME_OMITFINALDOT, buffer);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}

View file

@ -117,7 +117,8 @@ name_to_gbuffer(const dns_name_t *name, isc_buffer_t *buffer,
namep = &tname;
}
result = dns_name_toprincipal(namep, buffer);
result = dns_name_totext(
namep, DNS_NAME_OMITFINALDOT | DNS_NAME_PRINCIPAL, buffer);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_putuint8(buffer, 0);
isc_buffer_usedregion(buffer, &r);
@ -383,7 +384,8 @@ dst_gssapi_identitymatchesrealmkrb5(const dns_name_t *signer,
* a string, and do string operations on them.
*/
isc_buffer_init(&buffer, sbuf, sizeof(sbuf));
result = dns_name_toprincipal(signer, &buffer);
result = dns_name_totext(
signer, DNS_NAME_OMITFINALDOT | DNS_NAME_PRINCIPAL, &buffer);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_putuint8(&buffer, 0);
dns_name_format(realm, rbuf, sizeof(rbuf));
@ -461,7 +463,8 @@ dst_gssapi_identitymatchesrealmms(const dns_name_t *signer,
* a string, and do string operations on them.
*/
isc_buffer_init(&buffer, sbuf, sizeof(sbuf));
result = dns_name_toprincipal(signer, &buffer);
result = dns_name_totext(
signer, DNS_NAME_OMITFINALDOT | DNS_NAME_PRINCIPAL, &buffer);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
isc_buffer_putuint8(&buffer, 0);
dns_name_format(realm, rbuf, sizeof(rbuf));

View file

@ -797,30 +797,22 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
*/
#define DNS_NAME_OMITFINALDOT 0x01U
#define DNS_NAME_MASTERFILE 0x02U /* escape $ and @ */
#define DNS_NAME_PRINCIPAL 0x02U /* do not escape $ and @ */
isc_result_t
dns_name_toprincipal(const dns_name_t *name, isc_buffer_t *target);
isc_result_t
dns_name_totext(const dns_name_t *name, bool omit_final_dot,
dns_name_totext(const dns_name_t *name, unsigned int options,
isc_buffer_t *target);
isc_result_t
dns_name_totext2(const dns_name_t *name, unsigned int options,
isc_buffer_t *target);
/*%<
* Convert 'name' into text format, storing the result in 'target'.
*
* Notes:
*\li If 'omit_final_dot' is true, then the final '.' in absolute
* names other than the root name will be omitted.
*
*\li If DNS_NAME_OMITFINALDOT is set in options, then the final '.'
* in absolute names other than the root name will be omitted.
*
*\li If DNS_NAME_MASTERFILE is set in options, '$' and '@' will also
* be escaped.
*\li If DNS_NAME_PRINCIPAL is set in options, '$' and '@' will *not*
* be escaped; otherwise they will, along with other characters that
* are special in zone files ('"', '(', ')', '.', ';', and '\'),
* which are always escaped.
*
*\li If dns_name_countlabels == 0, the name will be "@", representing the
* current origin as described by RFC1035.
@ -831,9 +823,9 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
*
*\li 'name' is a valid name
*
*\li 'target' is a valid buffer.
*\li 'target' is a valid buffer
*
*\li if dns_name_isabsolute == FALSE, then omit_final_dot == FALSE
*\li if dns_name_isabsolute is false, then omit_final_dot is false
*
* Ensures:
*

View file

@ -503,7 +503,10 @@ ncache_summary(dns_rdataset_t *rdataset, bool omit_final_dot,
CHECK(str_totext("; ", target));
}
CHECK(dns_name_totext(&name, omit_final_dot, target));
CHECK(dns_name_totext(
&name,
omit_final_dot ? DNS_NAME_OMITFINALDOT : 0,
target));
CHECK(str_totext(" ", target));
CHECK(dns_rdatatype_totext(rds.type, target));
if (rds.type == dns_rdatatype_rrsig) {
@ -603,7 +606,10 @@ rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
!first))
{
unsigned int name_start = target->used;
RETERR(dns_name_totext(name, omit_final_dot, target));
RETERR(dns_name_totext(
name,
omit_final_dot ? DNS_NAME_OMITFINALDOT : 0,
target));
column += target->used - name_start;
}
@ -800,7 +806,8 @@ question_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
/* Owner name */
{
unsigned int name_start = target->used;
RETERR(dns_name_totext(owner_name, omit_final_dot, target));
unsigned int opts = omit_final_dot ? DNS_NAME_OMITFINALDOT : 0;
RETERR(dns_name_totext(owner_name, opts, target));
column += target->used - name_start;
}
@ -1055,7 +1062,7 @@ dump_rdatasets_text(isc_mem_t *mctx, const dns_name_t *name,
if (itresult == ISC_R_SUCCESS && ctx->neworigin != NULL) {
isc_buffer_clear(buffer);
itresult = dns_name_totext(ctx->neworigin, false, buffer);
itresult = dns_name_totext(ctx->neworigin, 0, buffer);
RUNTIME_CHECK(itresult == ISC_R_SUCCESS);
isc_buffer_usedregion(buffer, &r);
fprintf(f, "$ORIGIN %.*s\n", (int)r.length, (char *)r.base);

View file

@ -1098,24 +1098,8 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
}
isc_result_t
dns_name_totext(const dns_name_t *name, bool omit_final_dot,
dns_name_totext(const dns_name_t *name, unsigned int options,
isc_buffer_t *target) {
unsigned int options = DNS_NAME_MASTERFILE;
if (omit_final_dot) {
options |= DNS_NAME_OMITFINALDOT;
}
return (dns_name_totext2(name, options, target));
}
isc_result_t
dns_name_toprincipal(const dns_name_t *name, isc_buffer_t *target) {
return (dns_name_totext2(name, DNS_NAME_OMITFINALDOT, target));
}
isc_result_t
dns_name_totext2(const dns_name_t *name, unsigned int options,
isc_buffer_t *target) {
unsigned char *ndata;
char *tdata;
unsigned int nlen, tlen;
@ -1202,8 +1186,7 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
/* Special modifiers in zone files. */
case 0x40: /* '@' */
case 0x24: /* '$' */
if ((options & DNS_NAME_MASTERFILE) ==
0)
if ((options & DNS_NAME_PRINCIPAL) != 0)
{
goto no_escape;
}
@ -2020,7 +2003,7 @@ dns_name_print(const dns_name_t *name, FILE *stream) {
REQUIRE(VALID_NAME(name));
isc_buffer_init(&b, t, sizeof(t));
result = dns_name_totext(name, false, &b);
result = dns_name_totext(name, 0, &b);
if (result != ISC_R_SUCCESS) {
return (result);
}
@ -2061,7 +2044,7 @@ dns_name_format(const dns_name_t *name, char *cp, unsigned int size) {
* Leave room for null termination after buffer.
*/
isc_buffer_init(&buf, cp, size - 1);
result = dns_name_totext(name, true, &buf);
result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &buf);
if (result == ISC_R_SUCCESS) {
isc_buffer_putuint8(&buf, (uint8_t)'\0');
} else {
@ -2084,7 +2067,7 @@ dns_name_tostring(const dns_name_t *name, char **target, isc_mem_t *mctx) {
REQUIRE(target != NULL && *target == NULL);
isc_buffer_init(&buf, txt, sizeof(txt));
result = dns_name_totext(name, false, &buf);
result = dns_name_totext(name, 0, &buf);
if (result != ISC_R_SUCCESS) {
return (result);
}

View file

@ -551,7 +551,7 @@ dns_ntatable_save(dns_ntatable_t *ntatable, FILE *fp) {
}
isc_buffer_init(&b, nbuf, sizeof(nbuf));
result = dns_name_totext(n->name, false, &b);
result = dns_name_totext(n->name, 0, &b);
if (result != ISC_R_SUCCESS) {
continue;
}

View file

@ -139,9 +139,9 @@ totext_any_tsig(ARGS_TOTEXT) {
char *bufp;
dns_name_t name;
dns_name_t prefix;
bool sub;
uint64_t sigtime;
unsigned short n;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_tsig);
REQUIRE(rdata->rdclass == dns_rdataclass_any);
@ -154,8 +154,9 @@ totext_any_tsig(ARGS_TOTEXT) {
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_name_fromregion(&name, &sr);
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
isc_region_consume(&sr, name_length(&name));

View file

@ -69,7 +69,7 @@ totext_ch_a(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("0177777")];
uint16_t addr;
@ -85,8 +85,9 @@ totext_ch_a(ARGS_TOTEXT) {
isc_region_consume(&region, name_length(&name));
addr = uint16_fromregion(&region);
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
snprintf(buf, sizeof(buf), "%o", addr); /* note octal */
RETERR(str_totext(" ", target));

View file

@ -71,8 +71,7 @@ totext_afsdb(ARGS_TOTEXT) {
dns_name_t prefix;
isc_region_t region;
char buf[sizeof("64000 ")];
bool sub;
unsigned int num;
unsigned int num, opts;
REQUIRE(rdata->type == dns_rdatatype_afsdb);
REQUIRE(rdata->length != 0);
@ -86,8 +85,9 @@ totext_afsdb(ARGS_TOTEXT) {
snprintf(buf, sizeof(buf), "%u ", num);
RETERR(str_totext(buf, target));
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -174,7 +174,7 @@ totext_amtrelay(ARGS_TOTEXT) {
case 3:
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &region);
return (dns_name_totext(&name, false, target));
return (dns_name_totext(&name, 0, target));
default:
UNREACHABLE();

View file

@ -46,7 +46,7 @@ totext_cname(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_cname);
REQUIRE(rdata->length != 0);
@ -57,9 +57,9 @@ totext_cname(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -47,7 +47,7 @@ totext_dname(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_dname);
REQUIRE(rdata->length != 0);
@ -58,9 +58,9 @@ totext_dname(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -177,7 +177,7 @@ totext_hip(ARGS_TOTEXT) {
while (region.length > 0) {
dns_name_fromregion(&name, &region);
RETERR(dns_name_totext(&name, false, target));
RETERR(dns_name_totext(&name, 0, target));
isc_region_consume(&region, name.length);
if (region.length > 0) {
RETERR(str_totext(tctx->linebreak, target));

View file

@ -187,7 +187,7 @@ totext_ipseckey(ARGS_TOTEXT) {
case 3:
dns_name_fromregion(&name, &region);
RETERR(dns_name_totext(&name, false, target));
RETERR(dns_name_totext(&name, 0, target));
isc_region_consume(&region, name_length(&name));
break;
}

View file

@ -55,7 +55,7 @@ totext_lp(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -74,8 +74,9 @@ totext_lp(ARGS_TOTEXT) {
RETERR(str_totext(" ", target));
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -45,7 +45,7 @@ totext_mb(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_mb);
REQUIRE(rdata->length != 0);
@ -56,9 +56,9 @@ totext_mb(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -45,7 +45,7 @@ totext_md(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_md);
REQUIRE(rdata->length != 0);
@ -56,9 +56,9 @@ totext_md(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -45,7 +45,7 @@ totext_mf(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_mf);
REQUIRE(rdata->length != 0);
@ -56,9 +56,9 @@ totext_mf(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -45,7 +45,7 @@ totext_mg(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_mg);
REQUIRE(rdata->length != 0);
@ -56,9 +56,9 @@ totext_mg(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -61,7 +61,7 @@ totext_minfo(ARGS_TOTEXT) {
dns_name_t rmail;
dns_name_t email;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_minfo);
REQUIRE(rdata->length != 0);
@ -78,14 +78,17 @@ totext_minfo(ARGS_TOTEXT) {
dns_name_fromregion(&email, &region);
isc_region_consume(&region, email.length);
sub = name_prefix(&rmail, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&rmail, tctx->origin, &prefix)
? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
sub = name_prefix(&email, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&email, tctx->origin, &prefix)
? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -45,7 +45,7 @@ totext_mr(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_mr);
REQUIRE(rdata->length != 0);
@ -56,9 +56,9 @@ totext_mr(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -101,7 +101,7 @@ totext_mx(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -120,8 +120,9 @@ totext_mx(ARGS_TOTEXT) {
RETERR(str_totext(" ", target));
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -244,7 +244,7 @@ totext_naptr(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -296,8 +296,9 @@ totext_naptr(ARGS_TOTEXT) {
* Replacement.
*/
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -56,7 +56,7 @@ totext_ns(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_ns);
REQUIRE(rdata->length != 0);
@ -67,9 +67,9 @@ totext_ns(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -65,7 +65,7 @@ totext_nsec(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &sr);
dns_name_fromregion(&name, &sr);
isc_region_consume(&sr, name_length(&name));
RETERR(dns_name_totext(&name, false, target));
RETERR(dns_name_totext(&name, 0, target));
/*
* Don't leave a trailing space when there's no typemap present.
*/

View file

@ -91,10 +91,9 @@ fromtext_nxt(ARGS_FROMTEXT) {
static isc_result_t
totext_nxt(ARGS_TOTEXT) {
isc_region_t sr;
unsigned int i, j;
unsigned int i, j, opts;
dns_name_t name;
dns_name_t prefix;
bool sub;
REQUIRE(rdata->type == dns_rdatatype_nxt);
REQUIRE(rdata->length != 0);
@ -104,8 +103,9 @@ totext_nxt(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &sr);
dns_name_fromregion(&name, &sr);
isc_region_consume(&sr, name_length(&name));
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
for (i = 0; i < sr.length; i++) {
if (sr.base[i] != 0) {

View file

@ -58,7 +58,7 @@ totext_ptr(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_ptr);
REQUIRE(rdata->length != 0);
@ -69,9 +69,9 @@ totext_ptr(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -63,7 +63,7 @@ totext_rp(ARGS_TOTEXT) {
dns_name_t rmail;
dns_name_t email;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_rp);
REQUIRE(rdata->length != 0);
@ -80,13 +80,17 @@ totext_rp(ARGS_TOTEXT) {
dns_name_fromregion(&email, &region);
isc_region_consume(&region, email.length);
sub = name_prefix(&rmail, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&rmail, tctx->origin, &prefix)
? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
sub = name_prefix(&email, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&email, tctx->origin, &prefix)
? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -268,7 +268,7 @@ totext_rrsig(ARGS_TOTEXT) {
dns_name_init(&name, NULL);
dns_name_fromregion(&name, &sr);
isc_region_consume(&sr, name_length(&name));
RETERR(dns_name_totext(&name, false, target));
RETERR(dns_name_totext(&name, 0, target));
/*
* Sig.

View file

@ -65,7 +65,7 @@ totext_rt(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -82,8 +82,9 @@ totext_rt(ARGS_TOTEXT) {
RETERR(str_totext(buf, target));
RETERR(str_totext(" ", target));
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -150,7 +150,7 @@ totext_sig(ARGS_TOTEXT) {
unsigned long foot;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_sig);
REQUIRE(rdata->length != 0);
@ -235,8 +235,9 @@ totext_sig(ARGS_TOTEXT) {
dns_name_init(&prefix, NULL);
dns_name_fromregion(&name, &sr);
isc_region_consume(&sr, name_length(&name));
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
/*
* Sig.

View file

@ -85,7 +85,7 @@ totext_soa(ARGS_TOTEXT) {
dns_name_t mname;
dns_name_t rname;
dns_name_t prefix;
bool sub;
unsigned int opts;
int i;
bool multiline;
bool comm;
@ -112,13 +112,17 @@ totext_soa(ARGS_TOTEXT) {
dns_name_fromregion(&rname, &dregion);
isc_region_consume(&dregion, name_length(&rname));
sub = name_prefix(&mname, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&mname, tctx->origin, &prefix)
? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
sub = name_prefix(&rname, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&rname, tctx->origin, &prefix)
? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
if (multiline) {
RETERR(str_totext(" (", target));

View file

@ -52,7 +52,7 @@ totext_talink(ARGS_TOTEXT) {
dns_name_t prev;
dns_name_t next;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_talink);
REQUIRE(rdata->length != 0);
@ -69,13 +69,15 @@ totext_talink(ARGS_TOTEXT) {
dns_name_fromregion(&next, &dregion);
isc_region_consume(&dregion, name_length(&next));
sub = name_prefix(&prev, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&prev, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
sub = name_prefix(&next, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&next, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -126,7 +126,7 @@ totext_tkey(ARGS_TOTEXT) {
unsigned long n;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_tkey);
REQUIRE(rdata->length != 0);
@ -139,8 +139,9 @@ totext_tkey(ARGS_TOTEXT) {
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_name_fromregion(&name, &sr);
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
isc_region_consume(&sr, name_length(&name));

View file

@ -106,7 +106,7 @@ totext_in_a6(ARGS_TOTEXT) {
char buf[sizeof("128")];
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_a6);
REQUIRE(rdata->rdclass == dns_rdataclass_in);
@ -140,8 +140,9 @@ totext_in_a6(ARGS_TOTEXT) {
dns_name_init(&name, NULL);
dns_name_init(&prefix, NULL);
dns_name_fromregion(&name, &sr);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -54,7 +54,7 @@ totext_in_kx(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -74,8 +74,9 @@ totext_in_kx(ARGS_TOTEXT) {
RETERR(str_totext(" ", target));
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -48,7 +48,7 @@ totext_in_nsap_ptr(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
REQUIRE(rdata->type == dns_rdatatype_nsap_ptr);
REQUIRE(rdata->rdclass == dns_rdataclass_in);
@ -60,9 +60,9 @@ totext_in_nsap_ptr(ARGS_TOTEXT) {
dns_rdata_toregion(rdata, &region);
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -70,7 +70,7 @@ totext_in_px(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -95,17 +95,19 @@ totext_in_px(ARGS_TOTEXT) {
* MAP822.
*/
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
isc_region_consume(&region, name_length(&name));
RETERR(dns_name_totext(&prefix, sub, target));
RETERR(dns_name_totext(&prefix, opts, target));
RETERR(str_totext(" ", target));
/*
* MAPX400.
*/
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -91,7 +91,7 @@ totext_in_srv(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("64000")];
unsigned short num;
@ -134,8 +134,9 @@ totext_in_srv(ARGS_TOTEXT) {
* Target.
*/
dns_name_fromregion(&name, &region);
sub = name_prefix(&name, tctx->origin, &prefix);
return (dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
return (dns_name_totext(&prefix, opts, target));
}
static isc_result_t

View file

@ -660,7 +660,7 @@ generic_totext_in_svcb(ARGS_TOTEXT) {
isc_region_t region;
dns_name_t name;
dns_name_t prefix;
bool sub;
unsigned int opts;
char buf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];
unsigned short num;
int n;
@ -686,8 +686,9 @@ generic_totext_in_svcb(ARGS_TOTEXT) {
*/
dns_name_fromregion(&name, &region);
isc_region_consume(&region, name_length(&name));
sub = name_prefix(&name, tctx->origin, &prefix);
RETERR(dns_name_totext(&prefix, sub, target));
opts = name_prefix(&name, tctx->origin, &prefix) ? DNS_NAME_OMITFINALDOT
: 0;
RETERR(dns_name_totext(&prefix, opts, target));
while (region.length > 0) {
isc_region_t r;

View file

@ -956,7 +956,8 @@ make_log_buf(dns_rrl_t *rrl, dns_rrl_entry_t *e, const char *str1,
}
if (qname != NULL) {
ADD_LOG_CSTR(&lb, " for ");
(void)dns_name_totext(qname, true, &lb);
(void)dns_name_totext(qname, DNS_NAME_OMITFINALDOT,
&lb);
} else {
ADD_LOG_CSTR(&lb, " for (?)");
}

View file

@ -483,12 +483,12 @@ getnodedata(dns_db_t *db, const dns_name_t *name, bool create,
dns_name_countlabels(&sdlz->common.origin);
dns_name_init(&relname, NULL);
dns_name_getlabelsequence(name, 0, labels, &relname);
result = dns_name_totext(&relname, true, &b);
result = dns_name_totext(&relname, DNS_NAME_OMITFINALDOT, &b);
if (result != ISC_R_SUCCESS) {
return (result);
}
} else {
result = dns_name_totext(name, true, &b);
result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b);
if (result != ISC_R_SUCCESS) {
return (result);
}
@ -496,7 +496,8 @@ getnodedata(dns_db_t *db, const dns_name_t *name, bool create,
isc_buffer_putuint8(&b, 0);
isc_buffer_init(&b2, zonestr, sizeof(zonestr));
result = dns_name_totext(&sdlz->common.origin, true, &b2);
result = dns_name_totext(&sdlz->common.origin, DNS_NAME_OMITFINALDOT,
&b2);
if (result != ISC_R_SUCCESS) {
return (result);
}
@ -558,7 +559,8 @@ getnodedata(dns_db_t *db, const dns_name_t *name, bool create,
}
isc_buffer_init(&b, wildstr, sizeof(wildstr));
result = dns_name_totext(wild, true, &b);
result = dns_name_totext(wild, DNS_NAME_OMITFINALDOT,
&b);
if (result != ISC_R_SUCCESS) {
MAYBE_UNLOCK(sdlz->dlzimp);
return (result);
@ -693,7 +695,8 @@ createiterator(dns_db_t *db, unsigned int options,
}
isc_buffer_init(&b, zonestr, sizeof(zonestr));
result = dns_name_totext(&sdlz->common.origin, true, &b);
result = dns_name_totext(&sdlz->common.origin, DNS_NAME_OMITFINALDOT,
&b);
if (result != ISC_R_SUCCESS) {
return (result);
}
@ -1423,7 +1426,7 @@ dns_sdlzallowzonexfr(void *driverarg, void *dbdata, isc_mem_t *mctx,
/* Convert DNS name to ascii text */
isc_buffer_init(&b, namestr, sizeof(namestr));
result = dns_name_totext(name, true, &b);
result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b);
if (result != ISC_R_SUCCESS) {
return (result);
}
@ -1542,7 +1545,7 @@ dns_sdlzfindzone(void *driverarg, void *dbdata, isc_mem_t *mctx,
/* Convert DNS name to ascii text */
isc_buffer_init(&b, namestr, sizeof(namestr));
result = dns_name_totext(name, true, &b);
result = dns_name_totext(name, DNS_NAME_OMITFINALDOT, &b);
if (result != ISC_R_SUCCESS) {
return (result);
}

View file

@ -15347,7 +15347,8 @@ zone_namerd_tostr(dns_zone_t *zone, char *buf, size_t length) {
isc_buffer_init(&buffer, buf, (unsigned int)length - 1);
if (zone->type != dns_zone_redirect && zone->type != dns_zone_key) {
if (dns_name_dynamic(&zone->origin)) {
result = dns_name_totext(&zone->origin, true, &buffer);
result = dns_name_totext(
&zone->origin, DNS_NAME_OMITFINALDOT, &buffer);
}
if (result != ISC_R_SUCCESS &&
isc_buffer_availablelength(&buffer) >=
@ -15392,7 +15393,8 @@ zone_name_tostr(dns_zone_t *zone, char *buf, size_t length) {
*/
isc_buffer_init(&buffer, buf, (unsigned int)length - 1);
if (dns_name_dynamic(&zone->origin)) {
result = dns_name_totext(&zone->origin, true, &buffer);
result = dns_name_totext(&zone->origin, DNS_NAME_OMITFINALDOT,
&buffer);
}
if (result != ISC_R_SUCCESS &&
isc_buffer_availablelength(&buffer) >= (sizeof("<UNKNOWN>") - 1))