]> 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>
Fri, 4 Oct 2019 04:08:25 +0000 (14:08 +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.

(cherry picked from commit 89b269b0d28e0acf4a1f92414b5df2e86e2a008e)

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 0bf3517e75a7e7f64007838196c3063b310056ea..9f38ebd2eb117b476613651e6bd5ca6a269df574 100644 (file)
@@ -207,9 +207,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 067aeb81b4667be4e3ad64ece9d8aa3596a2321c..490d42c2f3b5b9d3d0f8d4f11c005ee2a9bc10fe 100644 (file)
@@ -181,9 +181,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 adf9e00dd77c41feb0709ba7ba6c910464e5b52a..5406e284613d57feb9c5ce6fe690b9bc076ed0de 100644 (file)
@@ -260,16 +260,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 4789091ec989d24e27fa0f206d1fe0ad247dc0d0..166c8dba7e19bba376654a48f72d4fe0ab08a668 100644 (file)
@@ -235,15 +235,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 b3a124fb0354ee8c5f9e70c199042673531d6272..6cf1283a45445685ddd45b307b702c9d72eef852 100644 (file)
@@ -3207,9 +3207,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 57038befe51c47f423a1735b1e9ef3b202f2fcf8..47c51559aa4d0a14766e6909db9862e7d02ac96b 100644 (file)
@@ -1419,9 +1419,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);
@@ -2235,9 +2233,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)
@@ -2274,7 +2270,6 @@ process_soa(updatectx_t *uctx, dns_rdataset_t *soaset,
                UNLOCK(&uctx->lock);
        }
 
- out:
        dns_rdata_freestruct(&soa);
 
        return (result);
@@ -2614,9 +2609,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 493fdb7e863f798e099d3c36cf4b8861950145a4..e3fa5ee953def6e5dab81c5cb0fd2b354724c06f 100644 (file)
@@ -595,7 +595,6 @@ rpsdb_finddb(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version,
             dns_rdataset_t *rdataset, dns_rdataset_t *sigrdataset)
 {
        dns_dbnode_t *node;
-       isc_result_t result;
 
        UNUSED(version);
        UNUSED(options);
@@ -607,9 +606,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 af00365cf269913062770f9b8b63091c5bc42dd2..4e9d7f3fccb8b9cde5af16694011754798e54604 100644 (file)
@@ -271,12 +271,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,
@@ -414,9 +412,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;
@@ -434,14 +430,6 @@ dns_lookup_create(isc_mem_t *mctx, const dns_name_t *name, dns_rdatatype_t type,
 
        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);
-
  cleanup_lookup:
        isc_mem_putanddetach(&mctx, lookup, sizeof(*lookup));
 
index 9f5b15d199e5e9dd94bee0199c0a19a6d9b16aa4..915f0bf41a470c52bbfb245b97155b6d4f1e8498 100644 (file)
@@ -1047,9 +1047,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 af28bd569d4142a4ab8bfae1d394e19edab1510e..0cd73a58c153d48a0abbb9483cf4c94e115477a3 100644 (file)
@@ -3062,7 +3062,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;
@@ -3083,9 +3082,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) {
                /*
@@ -3913,9 +3910,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 f38c1e6a1c267dc8913302e4dbe2d05b64d8d050..c66b3f888103166115de0f7d84f4d6a947295ff6 100644 (file)
@@ -5994,10 +5994,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
@@ -6630,9 +6627,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 88c62878c829b485e7a9723d2c213eac6d0e4701..bfcb39624347338b2bb48a852655f3547db1f325 100644 (file)
@@ -1031,16 +1031,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 61f275fa0fdad93a76f143873a0f784d2ca2c7cd..ae34414307a20f3acb25aa38c8e84aabf75c8653 100644 (file)
@@ -1033,16 +1033,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 25efba959b2a40f1f47263212e38cdf5df94316e..2868296487f81f1bce0b5245fee53f3a21bdea2d 100644 (file)
@@ -1318,9 +1318,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 &&
@@ -1361,6 +1359,7 @@ dns_view_findzonecut(dns_view_t *view, const dns_name_t *name,
                                 */
                                try_hints = true;
                        }
+                       result = ISC_R_SUCCESS;
                } else {
                        /*
                         * Something bad happened.
@@ -1377,13 +1376,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 &&
@@ -2202,9 +2197,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 0777a7cf5f552e97cc216191063fa34c28cf575e..2b11f1691e5f567037089cda866e06d34043dfe9 100644 (file)
@@ -6044,13 +6044,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) {