mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 18:59:59 -04:00
Add RUNTIME_CHECK() around result = dns_name_copy(..., NULL) calls
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 89b269b0d2)
This commit is contained in:
parent
9adb3ae2d5
commit
77fe5da647
15 changed files with 26 additions and 114 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue