mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -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.
This commit is contained in:
parent
35bd7e4da0
commit
89b269b0d2
15 changed files with 26 additions and 120 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue