]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
The final round of adding RUNTIME_CHECK() around dns_name_copy() calls
authorOndřej Surý <ondrej@sury.org>
Fri, 27 Sep 2019 06:37:26 +0000 (08:37 +0200)
committerMark Andrews <marka@isc.org>
Tue, 1 Oct 2019 00:43:26 +0000 (10:43 +1000)
This commit was done by hand to add the RUNTIME_CHECK() around stray
dns_name_copy() calls with NULL as third argument.  This covers the edge cases
that doesn't make sense to write a semantic patch since the usage pattern was
unique or almost unique.

bin/dig/dighost.c
lib/dns/client.c
lib/dns/rbt.c
lib/dns/rbtdb.c
lib/dns/resolver.c
lib/ns/query.c

index ca2cc977576d37e808d6287dd72aa419c2c92641..84a2a47141196a0d162ccd7589c377e55f9b29bb 100644 (file)
@@ -2154,22 +2154,26 @@ setup_lookup(dig_lookup_t *lookup) {
                        isc_buffer_init(&b, textname, len);
                        isc_buffer_add(&b, len);
                        result = dns_name_fromtext(name, &b, NULL, 0, NULL);
-                       if (result == ISC_R_SUCCESS &&
-                           !dns_name_isabsolute(name))
-                               result = dns_name_concatenate(name,
-                                                             lookup->oname,
-                                                             lookup->name,
-                                                             &lookup->namebuf);
-                       else if (result == ISC_R_SUCCESS)
-                               result = dns_name_copy(name, lookup->name,
-                                                      &lookup->namebuf);
+                       if (result == ISC_R_SUCCESS) {
+                               if (!dns_name_isabsolute(name)) {
+                                       result = dns_name_concatenate(name,
+                                                            lookup->oname,
+                                                            lookup->name,
+                                                            &lookup->namebuf);
+                               } else {
+                                       result = dns_name_copy(name,
+                                                            lookup->name,
+                                                            &lookup->namebuf);
+                               }
+                       }
                        if (result != ISC_R_SUCCESS) {
                                dns_message_puttempname(lookup->sendmsg,
                                                        &lookup->name);
                                dns_message_puttempname(lookup->sendmsg,
                                                        &lookup->oname);
-                               if (result == DNS_R_NAMETOOLONG)
+                               if (result == DNS_R_NAMETOOLONG) {
                                        return (false);
+                               }
                                fatal("'%s' is not in legal name syntax (%s)",
                                      lookup->textname,
                                      isc_result_totext(result));
index ad73cc206959624ad409698f81caa17c8dd9f7b3..6c639c2f5da73d82117219b244b0e5b0acd35a8a 100644 (file)
@@ -936,12 +936,10 @@ client_resfind(resctx_t *rctx, dns_fetchevent_t *event) {
                        dns_rdata_reset(&rdata);
                        if (tresult != ISC_R_SUCCESS)
                                goto done;
-                       tresult = dns_name_copy(&cname.cname, name, NULL);
+                       RUNTIME_CHECK(dns_name_copy(&cname.cname, name, NULL)
+                                     == ISC_R_SUCCESS);
                        dns_rdata_freestruct(&cname);
-                       if (tresult == ISC_R_SUCCESS)
-                               want_restart = true;
-                       else
-                               result = tresult;
+                       want_restart = true;
                        goto done;
                case DNS_R_DNAME:
                        /*
@@ -2832,7 +2830,8 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
                                   action, arg, sizeof(*uctx->event));
        if (zonename != NULL) {
                uctx->zonename = dns_fixedname_name(&uctx->zonefname);
-               result = dns_name_copy(zonename, uctx->zonename, NULL);
+               RUNTIME_CHECK(dns_name_copy(zonename, uctx->zonename, NULL)
+                             == ISC_R_SUCCESS);
        }
        if (servers != NULL) {
                for (server = ISC_LIST_HEAD(*servers);
index 378ec1a852f8a9e2a6164fe6a0c5d06fb76936c4..d6a3d25229d8614ec022213b60428ecd540bef2a 100644 (file)
@@ -3188,10 +3188,12 @@ dns_rbtnodechain_current(dns_rbtnodechain_t *chain, dns_name_t *name,
        }
 
        if (origin != NULL) {
-               if (chain->level_count > 0)
+               if (chain->level_count > 0) {
                        result = chain_name(chain, origin, false);
-               else
-                       result = dns_name_copy(dns_rootname, origin, NULL);
+               } else {
+                       RUNTIME_CHECK(dns_name_copy(dns_rootname, origin, NULL)
+                                     == ISC_R_SUCCESS);
+               }
        }
 
        return (result);
index 88e13a0dca83b0d3e878eb4ea390005d94e543ea..6cd6518fbf2d723485a748806e9e8029722fe18a 100644 (file)
@@ -4517,21 +4517,27 @@ find_deepest_zonecut(rbtdb_search_t *search, dns_rbtnode_t *node,
                        if (foundname != NULL) {
                                dns_name_init(&name, NULL);
                                dns_rbt_namefromnode(node, &name);
-                               result = dns_name_copy(&name, foundname, NULL);
-                               while (result == ISC_R_SUCCESS && i > 0) {
+                               RUNTIME_CHECK(dns_name_copy(&name, foundname,
+                                                           NULL)
+                                             == ISC_R_SUCCESS);
+                               while (i > 0) {
                                        i--;
                                        level_node = search->chain.levels[i];
                                        dns_name_init(&name, NULL);
                                        dns_rbt_namefromnode(level_node,
                                                             &name);
-                                       result =
-                                               dns_name_concatenate(foundname,
-                                                                    &name,
-                                                                    foundname,
-                                                                    NULL);
+                                       result = dns_name_concatenate(foundname,
+                                                                     &name,
+                                                                     foundname,
+                                                                     NULL);
+                                       if (result != ISC_R_SUCCESS) {
+                                               break;
+                                       }
                                }
                                if (result != ISC_R_SUCCESS) {
-                                       *nodep = NULL;
+                                       if (nodep != NULL) {
+                                               *nodep = NULL;
+                                       }
                                        goto node_exit;
                                }
                        }
index b7c2fcbf3ad2001ef604c883a74a957298ee3099..90a0d1b12012898d1395edad4e28bf4ab5ba5b16 100644 (file)
@@ -5192,7 +5192,6 @@ same_question(fetchctx_t *fctx) {
 static void
 clone_results(fetchctx_t *fctx) {
        dns_fetchevent_t *event, *hevent;
-       isc_result_t result;
        dns_name_t *name, *hname;
 
        FCTXTRACE("clone_results");
@@ -5213,11 +5212,9 @@ clone_results(fetchctx_t *fctx) {
             event != NULL;
             event = ISC_LIST_NEXT(event, ev_link)) {
                name = dns_fixedname_name(&event->foundname);
-               result = dns_name_copy(hname, name, NULL);
-               if (result != ISC_R_SUCCESS)
-                       event->result = result;
-               else
-                       event->result = hevent->result;
+               RUNTIME_CHECK(dns_name_copy(hname, name, NULL)
+                             == ISC_R_SUCCESS);
+               event->result = hevent->result;
                dns_db_attach(hevent->db, &event->db);
                dns_db_attachnode(hevent->db, hevent->node, &event->node);
                INSIST(hevent->rdataset != NULL);
index bd76a5364d2cdf7a2bea05fd3557bda35a2a61c7..d7a8b56124a55ec59cf00f4bcc4bd56c59dd11f6 100644 (file)
@@ -5515,11 +5515,8 @@ query_lookup(query_ctx_t *qctx) {
         * Fixup fname and sigrdataset.
         */
        if (qctx->dns64 && qctx->rpz) {
-               isc_result_t rresult;
-
-               rresult = dns_name_copy(qctx->client->query.qname,
-                                       qctx->fname, NULL);
-               RUNTIME_CHECK(rresult == ISC_R_SUCCESS);
+               RUNTIME_CHECK(dns_name_copy(qctx->client->query.qname,
+                                           qctx->fname, NULL) == ISC_R_SUCCESS);
                if (qctx->sigrdataset != NULL &&
                    dns_rdataset_isassociated(qctx->sigrdataset))
                {
@@ -5685,8 +5682,6 @@ static void
 recparam_update(ns_query_recparam_t *param, dns_rdatatype_t qtype,
                const dns_name_t *qname, const dns_name_t *qdomain)
 {
-       isc_result_t result;
-
        REQUIRE(param != NULL);
 
        param->qtype = qtype;
@@ -5695,16 +5690,16 @@ recparam_update(ns_query_recparam_t *param, dns_rdatatype_t qtype,
                param->qname = NULL;
        } else {
                param->qname = dns_fixedname_initname(&param->fqname);
-               result = dns_name_copy(qname, param->qname, NULL);
-               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+               RUNTIME_CHECK(dns_name_copy(qname, param->qname, NULL)
+                             == ISC_R_SUCCESS);
        }
 
        if (qdomain == NULL) {
                param->qdomain = NULL;
        } else {
                param->qdomain = dns_fixedname_initname(&param->fqdomain);
-               result = dns_name_copy(qdomain, param->qdomain, NULL);
-               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+               RUNTIME_CHECK(dns_name_copy(qdomain, param->qdomain, NULL)
+                             == ISC_R_SUCCESS);
        }
 }
 static atomic_uint_fast32_t last_soft, last_hard;
@@ -6375,9 +6370,9 @@ query_checkrpz(query_ctx_t *qctx, isc_result_t result) {
                 * we looked up even if we were stopped short
                 * in recursion or for a deferral.
                 */
-               rresult = dns_name_copy(qctx->client->query.qname,
-                                       qctx->fname, NULL);
-               RUNTIME_CHECK(rresult == ISC_R_SUCCESS);
+               RUNTIME_CHECK(dns_name_copy(qctx->client->query.qname,
+                                       qctx->fname, NULL)
+                             == ISC_R_SUCCESS);
                rpz_clean(&qctx->zone, &qctx->db, &qctx->node, NULL);
                if (qctx->rpz_st->m.rdataset != NULL) {
                        ns_client_putrdataset(qctx->client, &qctx->rdataset);
@@ -6550,8 +6545,8 @@ query_rpzcname(query_ctx_t *qctx, dns_name_t *cname) {
                        return (result);
                }
        } else {
-               result = dns_name_copy(cname, qctx->fname, NULL);
-               RUNTIME_CHECK(result == ISC_R_SUCCESS);
+               RUNTIME_CHECK(dns_name_copy(cname, qctx->fname, NULL)
+                             == ISC_R_SUCCESS);
        }
 
        ns_client_keepname(client, qctx->fname, qctx->dbuf);