]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Pull out the saving of the zone cut into a separate function
authorMark Andrews <marka@isc.org>
Wed, 13 Jun 2018 07:23:27 +0000 (17:23 +1000)
committerMichał Kępień <michal@isc.org>
Wed, 13 Jun 2018 10:55:32 +0000 (12:55 +0200)
bin/dnssec/dnssec-signzone.c

index 6976a6e9abe863b3b3999777742abc056b78e021..7259254dc4141139347ca78850c0e455063e8481 100644 (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;