Pull out the saving of the zone cut into a separate function

This commit is contained in:
Mark Andrews 2018-06-13 17:23:27 +10:00 committed by Michał Kępień
parent 75c0d85fc4
commit 7be900a98f

View file

@ -189,6 +189,19 @@ static dns_ttl_t maxttl = 0;
static void
sign(isc_task_t *task, isc_event_t *event);
/*%
* Store a copy of 'name' in 'fzonecut' and return a pointer to that copy.
*/
static dns_name_t *
savezonecut(dns_fixedname_t *fzonecut, dns_name_t *name) {
dns_name_t *result;
result = dns_fixedname_initname(fzonecut);
dns_name_copy(name, result, NULL);
return (result);
}
static void
dumpnode(dns_name_t *name, dns_dbnode_t *node) {
dns_rdataset_t rds;
@ -1485,15 +1498,15 @@ assignwork(isc_task_t *task, isc_task_t *worker) {
if (dns_name_issubdomain(name, gorigin) &&
(zonecut == NULL ||
!dns_name_issubdomain(name, zonecut))) {
if (is_delegation(gdb, gversion, gorigin, name, node, NULL)) {
zonecut = dns_fixedname_initname(&fzonecut);
dns_name_copy(name, zonecut, NULL);
if (is_delegation(gdb, gversion, gorigin,
name, node, NULL))
{
zonecut = savezonecut(&fzonecut, name);
if (!OPTOUT(nsec3flags) ||
secure(name, node))
found = ISC_TRUE;
} else if (has_dname(gdb, gversion, node)) {
zonecut = dns_fixedname_initname(&fzonecut);
dns_name_copy(name, zonecut, NULL);
zonecut = savezonecut(&fzonecut, name);
found = ISC_TRUE;
} else {
found = ISC_TRUE;
@ -1736,7 +1749,6 @@ nsecify(void) {
dns_rdataset_init(&rdataset);
name = dns_fixedname_initname(&fname);
nextname = dns_fixedname_initname(&fnextname);
dns_fixedname_init(&fzonecut);
zonecut = NULL;
/*
@ -1798,14 +1810,12 @@ nsecify(void) {
}
if (is_delegation(gdb, gversion, gorigin, name, node, &nsttl)) {
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(name, zonecut, NULL);
zonecut = savezonecut(&fzonecut, name);
remove_sigs(node, ISC_TRUE, 0);
if (generateds)
add_ds(name, node, nsttl);
} else if (has_dname(gdb, gversion, node)) {
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(name, zonecut, NULL);
zonecut = savezonecut(&fzonecut, name);
}
result = dns_dbiterator_next(dbiter);
@ -2212,7 +2222,6 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
dns_rdataset_init(&rdataset);
name = dns_fixedname_initname(&fname);
nextname = dns_fixedname_initname(&fnextname);
dns_fixedname_init(&fzonecut);
zonecut = NULL;
/*
@ -2247,8 +2256,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
}
if (has_dname(gdb, gversion, node)) {
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(name, zonecut, NULL);
zonecut = savezonecut(&fzonecut, name);
}
result = dns_dbiterator_next(dbiter);
@ -2274,8 +2282,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
if (is_delegation(gdb, gversion, gorigin,
nextname, nextnode, &nsttl))
{
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(nextname, zonecut, NULL);
zonecut = savezonecut(&fzonecut, nextname);
remove_sigs(nextnode, ISC_TRUE, 0);
if (generateds)
add_ds(nextname, nextnode, nsttl);
@ -2286,8 +2293,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
continue;
}
} else if (has_dname(gdb, gversion, nextnode)) {
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(nextname, zonecut, NULL);
zonecut = savezonecut(&fzonecut, nextname);
}
dns_db_detachnode(gdb, &nextnode);
break;
@ -2388,8 +2394,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
}
if (has_dname(gdb, gversion, node)) {
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(name, zonecut, NULL);
zonecut = savezonecut(&fzonecut, name);
}
result = dns_dbiterator_next(dbiter);
@ -2414,8 +2419,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
if (is_delegation(gdb, gversion, gorigin,
nextname, nextnode, NULL))
{
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(nextname, zonecut, NULL);
zonecut = savezonecut(&fzonecut, nextname);
if (OPTOUT(nsec3flags) &&
!secure(nextname, nextnode)) {
dns_db_detachnode(gdb, &nextnode);
@ -2423,8 +2427,7 @@ nsec3ify(unsigned int hashalg, dns_iterations_t iterations,
continue;
}
} else if (has_dname(gdb, gversion, nextnode)) {
zonecut = dns_fixedname_name(&fzonecut);
dns_name_copy(nextname, zonecut, NULL);
zonecut = savezonecut(&fzonecut, nextname);
}
dns_db_detachnode(gdb, &nextnode);
break;