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

Do not access dns_fixedname_t fields directly

Employ dns_fixedname_name() and dns_fixedname_initname() to no longer
directly access dns_fixedname_t fields.
This commit is contained in:
Michał Kępień
2018-03-29 10:17:37 +02:00
committed by Ondřej Surý
parent 4df4a8e731
commit 39ddf9991f

View File

@@ -120,15 +120,16 @@ main(int argc, char *argv[]) {
isc_buffer_init(&source, argv[0], len); isc_buffer_init(&source, argv[0], len);
isc_buffer_add(&source, len); isc_buffer_add(&source, len);
dns_fixedname_init(&oname); dns_fixedname_init(&oname);
result = dns_name_fromtext(&oname.name, &source, result = dns_name_fromtext(dns_fixedname_name(&oname),
dns_rootname, 0, NULL); &source, dns_rootname, 0,
NULL);
if (result != 0) { if (result != 0) {
fprintf(stderr, fprintf(stderr,
"dns_name_fromtext() failed: %s\n", "dns_name_fromtext() failed: %s\n",
dns_result_totext(result)); dns_result_totext(result));
exit(1); exit(1);
} }
origin = &oname.name; origin = dns_fixedname_name(&oname);
} }
} else if (concatenate) } else if (concatenate)
origin = NULL; origin = NULL;
@@ -142,8 +143,7 @@ main(int argc, char *argv[]) {
len = strlen(argv[1]); len = strlen(argv[1]);
isc_buffer_init(&source, argv[1], len); isc_buffer_init(&source, argv[1], len);
isc_buffer_add(&source, len); isc_buffer_add(&source, len);
dns_fixedname_init(&compname); comp = dns_fixedname_initname(&compname);
comp = &compname.name;
result = dns_name_fromtext(comp, &source, origin, result = dns_name_fromtext(comp, &source, origin,
0, NULL); 0, NULL);
if (result != 0) { if (result != 0) {
@@ -209,11 +209,12 @@ main(int argc, char *argv[]) {
if (concatenate) { if (concatenate) {
if (got_name) { if (got_name) {
printf("Concatenating.\n"); printf("Concatenating.\n");
result = dns_name_concatenate(&wname.name, result = dns_name_concatenate(
&wname2.name, dns_fixedname_name(&wname),
&wname2.name, dns_fixedname_name(&wname2),
NULL); dns_fixedname_name(&wname2),
name = &wname2.name; NULL);
name = dns_fixedname_name(&wname2);
if (result == ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) {
if (check_absolute && if (check_absolute &&
dns_name_countlabels(name) > 0) { dns_name_countlabels(name) > 0) {
@@ -331,9 +332,9 @@ main(int argc, char *argv[]) {
if (concatenate) { if (concatenate) {
if (got_name) if (got_name)
name = &wname2.name; name = dns_fixedname_name(&wname2);
else else
name = &wname.name; name = dns_fixedname_name(&wname);
} }
} }