Commit 899e5606 authored by Mark Andrews's avatar Mark Andrews Committed by Michał Kępień

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

(cherry picked from commit 7be900a9)
parent ff7015a0
......@@ -191,6 +191,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;
......@@ -1487,15 +1500,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;
......@@ -1738,7 +1751,6 @@ nsecify(void) {
dns_rdataset_init(&rdataset);
name = dns_fixedname_initname(&fname);
nextname = dns_fixedname_initname(&fnextname);
dns_fixedname_init(&fzonecut);
zonecut = NULL;
/*
......@@ -1800,14 +1812,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);
......@@ -2214,7 +2224,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;
/*
......@@ -2249,8 +2258,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);
......@@ -2276,8 +2284,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);
......@@ -2288,8 +2295,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;
......@@ -2390,8 +2396,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);
......@@ -2416,8 +2421,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);
......@@ -2425,8 +2429,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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment