]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add RUNTIME_CHECK() around result = dns_name_copy(..., NULL) calls
authorOndřej Surý <ondrej@sury.org>
Tue, 10 Sep 2019 11:55:18 +0000 (13:55 +0200)
committerMark Andrews <marka@isc.org>
Tue, 1 Oct 2019 00:43:26 +0000 (10:43 +1000)
This second commit uses second semantic patch to replace the calls to
dns_name_copy() with NULL as third argument where the result was stored in a
isc_result_t variable.  As the dns_name_copy(..., NULL) cannot fail gracefully
when the third argument is NULL, it was just a bunch of dead code.

Couple of manual tweaks (removing dead labels and unused variables) were
manually applied on top of the semantic patch.

15 files changed:
bin/dnssec/dnssec-dsfromkey.c
bin/dnssec/dnssec-importkey.c
bin/named/zoneconf.c
bin/tests/system/dyndb/driver/syncptr.c
lib/dns/adb.c
lib/dns/client.c
lib/dns/dnsrps.c
lib/dns/lookup.c
lib/dns/rbt.c
lib/dns/rbtdb.c
lib/dns/resolver.c
lib/dns/sdb.c
lib/dns/sdlz.c
lib/dns/view.c
lib/ns/query.c

index 610d23e36d952c2bd324445315e0b7ae19b6425e..e458f4978e1dbc015fb60d3d27d20274d7880838 100644 (file)
@@ -200,9 +200,7 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
        rdclass = dst_key_class(key);
 
        name = dns_fixedname_initname(&fixed);
-       result = dns_name_copy(dst_key_name(key), name, NULL);
-       if (result != ISC_R_SUCCESS)
-               fatal("can't copy name");
+       RUNTIME_CHECK(dns_name_copy(dst_key_name(key), name, NULL) == ISC_R_SUCCESS);
 
        dst_key_free(&key);
 }
index c97bfe3624ea5de640d558c6cce80da5f69a69a7..b0ba9948b8aec1a385283dac36503bb8addebc20 100644 (file)
@@ -174,9 +174,7 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
        rdclass = dst_key_class(key);
 
        name = dns_fixedname_initname(&fixed);
-       result = dns_name_copy(dst_key_name(key), name, NULL);
-       if (result != ISC_R_SUCCESS)
-               fatal("can't copy name");
+       RUNTIME_CHECK(dns_name_copy(dst_key_name(key), name, NULL) == ISC_R_SUCCESS);
 
        dst_key_free(&key);
 }
index 29f654851ede0cb4e9e42d640ef9873ede61b54a..8b519b2569086c65392e9a2bfd78bb72e617bb06 100644 (file)
@@ -258,16 +258,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
 
                dns_fixedname_init(&fname);
                if (usezone) {
-                       result = dns_name_copy(dns_zone_getorigin(zone),
-                                              dns_fixedname_name(&fname),
-                                              NULL);
-                       if (result != ISC_R_SUCCESS) {
-                               cfg_obj_log(identity, named_g_lctx,
-                                           ISC_LOG_ERROR,
-                                           "error copying origin: %s",
-                                           isc_result_totext(result));
-                               goto cleanup;
-                       }
+                       RUNTIME_CHECK(dns_name_copy(dns_zone_getorigin(zone), dns_fixedname_name(&fname), NULL) == ISC_R_SUCCESS);
                } else {
                        str = cfg_obj_asstring(dname);
                        isc_buffer_constinit(&b, str, strlen(str));
index dc917c5ab001343560a08c6cc75cb229d41f8b60..2c3a2a6758642462fcb9204fd6e32daa9b988a8e 100644 (file)
@@ -229,15 +229,7 @@ syncptr(sample_instance_t *inst, dns_name_t *name,
        /* Reverse zone is managed by this driver, prepare PTR record */
        pevent->zone = NULL;
        dns_zone_attach(ptr_zone, &pevent->zone);
-       result = dns_name_copy(name,
-                              dns_fixedname_name(&pevent->ptr_target_name),
-                              NULL);
-       if (result != ISC_R_SUCCESS) {
-               log_write(ISC_LOG_ERROR,
-                         "syncptr: dns_name_copy -> %s\n",
-                         isc_result_totext(result));
-               goto cleanup;
-       }
+       RUNTIME_CHECK(dns_name_copy(name, dns_fixedname_name(&pevent->ptr_target_name), NULL) == ISC_R_SUCCESS);
        dns_name_clone(dns_fixedname_name(&pevent->ptr_target_name),
                       &ptr_struct.ptr);
        dns_diff_init(inst->mctx, &pevent->diff);
index 89bec9675cd812b70733e7f81755d6eb2cff6807..c4d201427f4730783bfb3b41b12ed0a46b211c04 100644 (file)
@@ -3203,9 +3203,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_task_t *task, isc_taskaction_t action,
        find->partial_result |= (adbname->partial_result & wanted_addresses);
        if (alias) {
                if (target != NULL) {
-                       result = dns_name_copy(&adbname->target, target, NULL);
-                       if (result != ISC_R_SUCCESS)
-                               goto out;
+                       RUNTIME_CHECK(dns_name_copy(&adbname->target, target, NULL) == ISC_R_SUCCESS);
                }
                result = DNS_R_ALIAS;
        } else
index 3d17909132563c50ca24fb26dadde6fdcf0e1bf0..ad73cc206959624ad409698f81caa17c8dd9f7b3 100644 (file)
@@ -1365,9 +1365,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
        rctx->sigrdataset = sigrdataset;
 
        dns_fixedname_init(&rctx->name);
-       result = dns_name_copy(name, dns_fixedname_name(&rctx->name), NULL);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup;
+       RUNTIME_CHECK(dns_name_copy(name, dns_fixedname_name(&rctx->name), NULL) == ISC_R_SUCCESS);
 
        rctx->client = client;
        ISC_LINK_INIT(rctx, link);
@@ -2167,9 +2165,7 @@ process_soa(updatectx_t *uctx, dns_rdataset_t *soaset,
 
        if (uctx->zonename == NULL) {
                uctx->zonename = dns_fixedname_name(&uctx->zonefname);
-               result = dns_name_copy(soaname, uctx->zonename, NULL);
-               if (result != ISC_R_SUCCESS)
-                       goto out;
+               RUNTIME_CHECK(dns_name_copy(soaname, uctx->zonename, NULL) == ISC_R_SUCCESS);
        }
 
        if (uctx->currentserver != NULL)
@@ -2206,7 +2202,6 @@ process_soa(updatectx_t *uctx, dns_rdataset_t *soaset,
                UNLOCK(&uctx->lock);
        }
 
- out:
        dns_rdata_freestruct(&soa);
 
        return (result);
@@ -2546,9 +2541,7 @@ copy_name(isc_mem_t *mctx, dns_message_t *msg, const dns_name_t *name,
        dns_name_init(newname, NULL);
        dns_name_setbuffer(newname, namebuf);
        dns_message_takebuffer(msg, &namebuf);
-       result = dns_name_copy(name, newname, NULL);
-       if (result != ISC_R_SUCCESS)
-               goto fail;
+       RUNTIME_CHECK(dns_name_copy(name, newname, NULL) == ISC_R_SUCCESS);
 
        for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL;
             rdataset = ISC_LIST_NEXT(rdataset, link)) {
index 2e33a0d19e9169ad2cb606f27832ccc3838721ae..f152e87e1eabcca2c170761e05f9272a25409614 100644 (file)
@@ -603,9 +603,7 @@ rpsdb_finddb(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
                nodep = &node;
        }
        rpsdb_findnode(db, name, false, nodep);
-       result = dns_name_copy(name, foundname, NULL);
-       if (result != ISC_R_SUCCESS)
-               return (result);
+       RUNTIME_CHECK(dns_name_copy(name, foundname, NULL) == ISC_R_SUCCESS);
        return (rpsdb_findrdataset(db, *nodep, NULL, type, 0, 0,
                                    rdataset, sigrdataset));
 }
index c555419a3a98a1fd8a72ac5b1d506fd9b20c9ccd..6c490b87083607e13cb3ee15d224fe2162675fe5 100644 (file)
@@ -257,12 +257,10 @@ lookup_find(dns_lookup_t *lookup, dns_fetchevent_t *event) {
                        dns_rdata_reset(&rdata);
                        if (result != ISC_R_SUCCESS)
                                break;
-                       result = dns_name_copy(&cname.cname, name, NULL);
+                       RUNTIME_CHECK(dns_name_copy(&cname.cname, name, NULL) == ISC_R_SUCCESS);
                        dns_rdata_freestruct(&cname);
-                       if (result == ISC_R_SUCCESS) {
-                               want_restart = true;
-                               send_event = false;
-                       }
+                       want_restart = true;
+                       send_event = false;
                        break;
                case DNS_R_DNAME:
                        namereln = dns_name_fullcompare(name, fname, &order,
@@ -366,7 +364,6 @@ dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
                  dns_view_t *view, unsigned int options, isc_task_t *task,
                  isc_taskaction_t action, void *arg, dns_lookup_t **lookupp)
 {
-       isc_result_t result;
        dns_lookup_t *lookup;
        isc_event_t *ievent;
 
@@ -394,9 +391,7 @@ dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
 
        dns_fixedname_init(&lookup->name);
 
-       result = dns_name_copy(name, dns_fixedname_name(&lookup->name), NULL);
-       if (result != ISC_R_SUCCESS)
-               goto cleanup_lock;
+       RUNTIME_CHECK(dns_name_copy(name, dns_fixedname_name(&lookup->name), NULL) == ISC_R_SUCCESS);
 
        lookup->type = type;
        lookup->view = NULL;
@@ -413,18 +408,6 @@ dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
        lookup_find(lookup, NULL);
 
        return (ISC_R_SUCCESS);
-
- cleanup_lock:
-       isc_mutex_destroy(&lookup->lock);
-       ievent = (isc_event_t *)lookup->event;
-       isc_event_free(&ievent);
-       lookup->event = NULL;
-
-       isc_task_detach(&lookup->task);
-
-       isc_mem_putanddetach(&mctx, lookup, sizeof(*lookup));
-
-       return (result);
 }
 
 void
index 29a61fa3b65c7410bffcfed8a958d76adf0eb8fd..378ec1a852f8a9e2a6164fe6a0c5d06fb76936c4 100644 (file)
@@ -1043,9 +1043,7 @@ chain_name(dns_rbtnodechain_t *chain, dns_name_t *name,
 
        if (include_chain_end && chain->end != NULL) {
                NODENAME(chain->end, &nodename);
-               result = dns_name_copy(&nodename, name, NULL);
-               if (result != ISC_R_SUCCESS)
-                       return (result);
+               RUNTIME_CHECK(dns_name_copy(&nodename, name, NULL) == ISC_R_SUCCESS);
        } else
                dns_name_reset(name);
 
index 47d198ec14366f566bed5e678010b149b4870b9f..88e13a0dca83b0d3e878eb4ea390005d94e543ea 100644 (file)
@@ -3020,7 +3020,6 @@ setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
                 dns_name_t *foundname, dns_rdataset_t *rdataset,
                 dns_rdataset_t *sigrdataset)
 {
-       isc_result_t result;
        dns_name_t *zcname;
        rbtdb_rdatatype_t type;
        dns_rbtnode_t *node;
@@ -3041,9 +3040,7 @@ setup_delegation(rbtdb_search_t *search, dns_dbnode_t **nodep,
         */
        if (foundname != NULL && search->copy_name) {
                zcname = dns_fixedname_name(&search->zonecut_name);
-               result = dns_name_copy(zcname, foundname, NULL);
-               if (result != ISC_R_SUCCESS)
-                       return (result);
+               RUNTIME_CHECK(dns_name_copy(zcname, foundname, NULL) == ISC_R_SUCCESS);
        }
        if (nodep != NULL) {
                /*
@@ -3871,9 +3868,7 @@ zone_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
                         */
                        result = find_wildcard(&search, &node, name);
                        if (result == ISC_R_SUCCESS) {
-                               result = dns_name_copy(name, foundname, NULL);
-                               if (result != ISC_R_SUCCESS)
-                                       goto tree_exit;
+                               RUNTIME_CHECK(dns_name_copy(name, foundname, NULL) == ISC_R_SUCCESS);
                                wild = true;
                                goto found;
                        }
index 3b0bea495b1ffad6eea4d9093a9a77a042cf5eb5..b7c2fcbf3ad2001ef604c883a74a957298ee3099 100644 (file)
@@ -5938,10 +5938,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_adbaddrinfo_t *addrinfo,
                if (event != NULL) {
                        adbp = &event->db;
                        aname = dns_fixedname_name(&event->foundname);
-                       result = dns_name_copy(name, aname, NULL);
-                       if (result != ISC_R_SUCCESS) {
-                               return (result);
-                       }
+                       RUNTIME_CHECK(dns_name_copy(name, aname, NULL) == ISC_R_SUCCESS);
                        anodep = &event->node;
                        /*
                         * If this is an ANY, SIG or RRSIG query, we're not
@@ -6569,9 +6566,7 @@ ncache_message(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
                if (event != NULL) {
                        adbp = &event->db;
                        aname = dns_fixedname_name(&event->foundname);
-                       result = dns_name_copy(name, aname, NULL);
-                       if (result != ISC_R_SUCCESS)
-                               goto unlock;
+                       RUNTIME_CHECK(dns_name_copy(name, aname, NULL) == ISC_R_SUCCESS);
                        anodep = &event->node;
                        ardataset = event->rdataset;
                }
index 019d50f5e99bb06b95bdb5424615c06741358797..2bd15fee3fbb3ab42c05276ae376619c22f87510 100644 (file)
@@ -998,16 +998,7 @@ findext(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
                dns_rdataset_disassociate(rdataset);
 
        if (foundname != NULL) {
-               isc_result_t xresult;
-
-               xresult = dns_name_copy(xname, foundname, NULL);
-               if (xresult != ISC_R_SUCCESS) {
-                       if (node != NULL)
-                               destroynode(node);
-                       if (dns_rdataset_isassociated(rdataset))
-                               dns_rdataset_disassociate(rdataset);
-                       return (DNS_R_BADDB);
-               }
+               RUNTIME_CHECK(dns_name_copy(xname, foundname, NULL) == ISC_R_SUCCESS);
        }
 
        if (nodep != NULL)
index 69d9096cc3b09a72d53153138ed0315099eb7d28..df0828699bbfa93080c6bdace01d2318278d2b09 100644 (file)
@@ -997,18 +997,7 @@ findext(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
                dns_rdataset_disassociate(rdataset);
 
        if (foundname != NULL) {
-               isc_result_t xresult;
-
-               xresult = dns_name_copy(xname, foundname, NULL);
-               if (xresult != ISC_R_SUCCESS) {
-                       if (node != NULL) {
-                               detachnode(db, &node);
-                       }
-                       if (dns_rdataset_isassociated(rdataset)) {
-                               dns_rdataset_disassociate(rdataset);
-                       }
-                       return (DNS_R_BADDB);
-               }
+               RUNTIME_CHECK(dns_name_copy(xname, foundname, NULL) == ISC_R_SUCCESS);
        }
 
        if (nodep != NULL)
index 2712df9e3d11a9783bfeeae1a09071e5de171c82..fd3f166a86a972513e8ee54bceac6207db02ad8a 100644 (file)
@@ -1297,9 +1297,7 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
                         * We found an answer, but the cache may be better.
                         */
                        zfname = dns_fixedname_name(&zfixedname);
-                       result = dns_name_copy(fname, zfname, NULL);
-                       if (result != ISC_R_SUCCESS)
-                               goto cleanup;
+                       RUNTIME_CHECK(dns_name_copy(fname, zfname, NULL) == ISC_R_SUCCESS);
                        dns_rdataset_clone(rdataset, &zrdataset);
                        dns_rdataset_disassociate(rdataset);
                        if (sigrdataset != NULL &&
@@ -1340,6 +1338,7 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
                                 */
                                try_hints = true;
                        }
+                       result = ISC_R_SUCCESS;
                } else {
                        /*
                         * Something bad happened.
@@ -1356,13 +1355,9 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
                            dns_rdataset_isassociated(sigrdataset))
                                dns_rdataset_disassociate(sigrdataset);
                }
-               result = dns_name_copy(zfname, fname, NULL);
-               if (result != ISC_R_SUCCESS)
-                       goto cleanup;
+               RUNTIME_CHECK(dns_name_copy(zfname, fname, NULL) == ISC_R_SUCCESS);
                if (dcname != NULL) {
-                       result = dns_name_copy(zfname, dcname, NULL);
-                       if (result != ISC_R_SUCCESS)
-                               goto cleanup;
+                       RUNTIME_CHECK(dns_name_copy(zfname, dcname, NULL) == ISC_R_SUCCESS);
                }
                dns_rdataset_clone(&zrdataset, rdataset);
                if (sigrdataset != NULL &&
@@ -2165,9 +2160,7 @@ dns_view_searchdlz(dns_view_t *view, const dns_name_t *name,
                 */
                for (i = namelabels; i > minlabels && i > 1; i--) {
                        if (i == namelabels) {
-                               result = dns_name_copy(name, zonename, NULL);
-                               if (result != ISC_R_SUCCESS)
-                                       return (result);
+                               RUNTIME_CHECK(dns_name_copy(name, zonename, NULL) == ISC_R_SUCCESS);
                        } else
                                dns_name_split(name, i, NULL, zonename);
 
index 6b04182411803abab0948f8ec943843cd87c9a97..bd76a5364d2cdf7a2bea05fd3557bda35a2a61c7 100644 (file)
@@ -6054,13 +6054,7 @@ query_resume(query_ctx_t *qctx) {
                tname = dns_fixedname_name(&qctx->event->foundname);
        }
 
-       result = dns_name_copy(tname, qctx->fname, NULL);
-       if (result != ISC_R_SUCCESS) {
-               CCTRACE(ISC_LOG_ERROR,
-                      "query_resume: dns_name_copy failed");
-               QUERY_ERROR(qctx, result);
-               return (ns_query_done(qctx));
-       }
+       RUNTIME_CHECK(dns_name_copy(tname, qctx->fname, NULL) == ISC_R_SUCCESS);
 
        if (qctx->rpz_st != NULL &&
            (qctx->rpz_st->state & DNS_RPZ_RECURSING) != 0) {