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

(cherry picked from commit 5efa29e03afc6c29aff881efe9d9b188bff65e46)

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

index 07d0da597239f07091c0e45d03d82462983c15d0..0311496e5212dab01bd92d78a42944d90b3806f9 100644 (file)
@@ -2138,22 +2138,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 47c51559aa4d0a14766e6909db9862e7d02ac96b..a47d8d827456c8643b313d5566e06aa479fc79de 100644 (file)
@@ -984,12 +984,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:
                        /*
@@ -2908,7 +2906,8 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
                goto fail;
        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 915f0bf41a470c52bbfb245b97155b6d4f1e8498..5f87cceaf97ad450a83b9a5c0ff51f6539757599 100644 (file)
@@ -3209,10 +3209,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 0cd73a58c153d48a0abbb9483cf4c94e115477a3..48eede69959904dda59dbd87cb828ab9ab4c1294 100644 (file)
@@ -4559,21 +4559,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 c66b3f888103166115de0f7d84f4d6a947295ff6..f4865bcda402910bf91231dd97c98ee81ad6ccd8 100644 (file)
@@ -5244,7 +5244,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");
@@ -5265,11 +5264,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 4600806b4f6ea7e3ea833a25152dba1a67711199..31126dab05788a574f62c59a6e641b87711e4737 100644 (file)
@@ -3147,7 +3147,7 @@ finddlvsep(dns_validator_t *val, bool resume) {
                }
 
                dlvsep = dns_fixedname_initname(&val->dlvsep);
-               dns_name_copy(val->event->name, dlvsep, NULL);
+               RUNTIME_CHECK(dns_name_copy(val->event->name, dlvsep, NULL) == ISC_R_SUCCESS);
                /*
                 * If this is a response to a DS query, we need to look in
                 * the parent zone for the trust anchor.
@@ -3198,9 +3198,7 @@ finddlvsep(dns_validator_t *val, bool resume) {
                            dns_rdataset_isassociated(&val->fsigrdataset))
                        {
                                dns_fixedname_init(&val->fname);
-                               dns_name_copy(dlvname,
-                                             dns_fixedname_name(&val->fname),
-                                             NULL);
+                               RUNTIME_CHECK(dns_name_copy(dlvname, dns_fixedname_name(&val->fname), NULL) == ISC_R_SUCCESS);
                                result = create_validator(val,
                                                dns_fixedname_name(&val->fname),
                                                          dns_rdatatype_dlv,
index 2b11f1691e5f567037089cda866e06d34043dfe9..42d5242aef0c468e5ad3b074ea4d0081b49d5d05 100644 (file)
@@ -5518,11 +5518,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))
                {
@@ -5688,8 +5685,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;
@@ -5698,16 +5693,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);
        }
 }
 
@@ -6365,9 +6360,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);
@@ -6540,8 +6535,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);