2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Merge branch 'marka-coverity-master' into 'master'

Address various minor issues identified by coverity on master

See merge request isc-projects/bind9!2999
This commit is contained in:
Mark Andrews 2020-02-05 08:13:16 +00:00
commit dd6598f391
13 changed files with 56 additions and 111 deletions

View File

@ -10065,8 +10065,7 @@ named_add_reserved_dispatch(named_server_t *server,
return; return;
cleanup: cleanup:
if (dispatch != NULL) isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
isc_mem_put(server->mctx, dispatch, sizeof(*dispatch));
isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf)); isc_sockaddr_format(addr, addrbuf, sizeof(addrbuf));
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING, NAMED_LOGMODULE_SERVER, ISC_LOG_WARNING,
@ -11028,8 +11027,7 @@ named_server_dumpdb(named_server_t *server, isc_lex_t *lex,
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
cleanup: cleanup:
if (dctx != NULL) dumpcontext_destroy(dctx);
dumpcontext_destroy(dctx);
return (result); return (result);
} }
@ -13835,10 +13833,6 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex,
dns_zone_detach(&raw); dns_zone_detach(&raw);
if (zone != NULL) if (zone != NULL)
dns_zone_detach(&zone); dns_zone_detach(&zone);
if (dz != NULL) {
dns_zone_detach(&dz->zone);
isc_mem_put(named_g_mctx, dz, sizeof(*dz));
}
return (result); return (result);
} }

View File

@ -120,8 +120,7 @@ dyndb_init(isc_mem_t *mctx, const char *name, const char *parameters,
*instp = sample_inst; *instp = sample_inst;
cleanup: cleanup:
if (s != NULL) isc_mem_free(mctx, s);
isc_mem_free(mctx, s);
if (argv != NULL) if (argv != NULL)
isc_mem_put(mctx, argv, argc * sizeof(*argv)); isc_mem_put(mctx, argv, argc * sizeof(*argv));

View File

@ -157,7 +157,7 @@ is_safe(const char *input) {
return (true); return (true);
} }
static isc_result_t static void
create_path_helper(char *out, const char *in, config_data_t *cd) { create_path_helper(char *out, const char *in, config_data_t *cd) {
char *tmpString; char *tmpString;
char *tmpPtr; char *tmpPtr;
@ -206,7 +206,6 @@ create_path_helper(char *out, const char *in, config_data_t *cd) {
} }
isc_mem_free(named_g_mctx, tmpString); isc_mem_free(named_g_mctx, tmpString);
return (ISC_R_SUCCESS);
} }
/*% /*%
@ -223,7 +222,6 @@ create_path(const char *zone, const char *host, const char *client,
char *tmpPath; char *tmpPath;
int pathsize; int pathsize;
int len; int len;
isc_result_t result;
bool isroot = false; bool isroot = false;
/* we require a zone & cd parameter */ /* we require a zone & cd parameter */
@ -285,9 +283,7 @@ create_path(const char *zone, const char *host, const char *client,
/* add zone name - parsed properly */ /* add zone name - parsed properly */
if (!isroot) { if (!isroot) {
result = create_path_helper(tmpPath, zone, cd); create_path_helper(tmpPath, zone, cd);
if (result != ISC_R_SUCCESS)
goto cleanup_mem;
} }
/* /*
@ -322,26 +318,13 @@ create_path(const char *zone, const char *host, const char *client,
/* if host not null, add it. */ /* if host not null, add it. */
if (host != NULL) { if (host != NULL) {
strncat(tmpPath, (char *) &cd->pathsep, 1); strncat(tmpPath, (char *) &cd->pathsep, 1);
if ((result = create_path_helper(tmpPath, host, create_path_helper(tmpPath, host, cd);
cd)) != ISC_R_SUCCESS)
goto cleanup_mem;
} }
/* return the path we built. */ /* return the path we built. */
*path = tmpPath; *path = tmpPath;
/* return success */ return (ISC_R_SUCCESS);
result = ISC_R_SUCCESS;
cleanup_mem:
/* cleanup memory */
/* free tmpPath memory */
if (tmpPath != NULL && result != ISC_R_SUCCESS)
isc_mem_free(named_g_mctx, tmpPath);
/* free tmpPath memory */
return (result);
} }
static isc_result_t static isc_result_t
@ -705,19 +688,18 @@ fs_allnodes(const char *zone, void *driverarg, void *dbdata,
} /* end while */ } /* end while */
complete_allnds: complete_allnds:
if (dir_list != NULL) { /* clean up entries from list. */
/* clean up entries from list. */ dir_entry = ISC_LIST_HEAD(*dir_list);
dir_entry = ISC_LIST_HEAD(*dir_list); while (dir_entry != NULL) {
while (dir_entry != NULL) { next_de = ISC_LIST_NEXT(dir_entry, link);
next_de = ISC_LIST_NEXT(dir_entry, link); isc_mem_put(named_g_mctx, dir_entry, sizeof(dir_entry_t));
isc_mem_put(named_g_mctx, dir_entry, sizeof(dir_entry_t)); dir_entry = next_de;
dir_entry = next_de; } /* end while */
} /* end while */ isc_mem_put(named_g_mctx, dir_list, sizeof(dlist_t));
isc_mem_put(named_g_mctx, dir_list, sizeof(dlist_t));
}
if (basepath != NULL) if (basepath != NULL) {
isc_mem_free(named_g_mctx, basepath); isc_mem_free(named_g_mctx, basepath);
}
return (result); return (result);
} }

View File

@ -254,8 +254,7 @@ build_querylist(isc_mem_t *mctx, const char *query_str, char **zone,
flag_fail: flag_fail:
/* get rid of what was build of the query list */ /* get rid of what was build of the query list */
if (tql != NULL) destroy_querylist(mctx, &tql);
destroy_querylist(mctx, &tql);
return result; return result;
} }

View File

@ -1655,9 +1655,7 @@ dns_catz_generate_zonecfg(dns_catz_zone_t *zone, dns_catz_entry_t *entry,
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
cleanup: cleanup:
if (buffer != NULL) { isc_buffer_free(&buffer);
isc_buffer_free(&buffer);
}
return (result); return (result);
} }

View File

@ -1393,8 +1393,7 @@ dns_client_startresolve(dns_client_t *client, const dns_name_t *name,
isc_mutex_destroy(&rctx->lock); isc_mutex_destroy(&rctx->lock);
isc_mem_put(mctx, rctx, sizeof(*rctx)); isc_mem_put(mctx, rctx, sizeof(*rctx));
} }
if (event != NULL) isc_event_free(ISC_EVENT_PTR(&event));
isc_event_free(ISC_EVENT_PTR(&event));
isc_task_detach(&tclone); isc_task_detach(&tclone);
dns_view_detach(&view); dns_view_detach(&view);
@ -1489,7 +1488,6 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass,
{ {
isc_result_t result; isc_result_t result;
dns_view_t *view = NULL; dns_view_t *view = NULL;
dst_key_t *dstkey = NULL;
dns_keytable_t *secroots = NULL; dns_keytable_t *secroots = NULL;
dns_name_t *name = NULL; dns_name_t *name = NULL;
char dsbuf[DNS_DS_BUFFERSIZE]; char dsbuf[DNS_DS_BUFFERSIZE];
@ -1534,9 +1532,6 @@ dns_client_addtrustedkey(dns_client_t *client, dns_rdataclass_t rdclass,
CHECK(dns_keytable_add(secroots, false, false, name, &ds)); CHECK(dns_keytable_add(secroots, false, false, name, &ds));
cleanup: cleanup:
if (dstkey != NULL) {
dst_key_free(&dstkey);
}
if (view != NULL) { if (view != NULL) {
dns_view_detach(&view); dns_view_detach(&view);
} }

View File

@ -126,26 +126,6 @@ dns_ipkeylist_copy(isc_mem_t *mctx, const dns_ipkeylist_t *src,
} }
dst->count = src->count; dst->count = src->count;
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
do {
if (dst->labels[i] != NULL) {
if (dns_name_dynamic(dst->labels[i]))
dns_name_free(dst->labels[i], mctx);
isc_mem_put(mctx, dst->labels[i], sizeof(dns_name_t));
dst->labels[i] = NULL;
}
} while (i-- > 0);
do {
if (dst->keys[i] != NULL) {
if (dns_name_dynamic(dst->keys[i]))
dns_name_free(dst->keys[i], mctx);
isc_mem_put(mctx, dst->keys[i], sizeof(dns_name_t));
dst->keys[i] = NULL;
}
} while (i-- > 0);
return (result);
} }
isc_result_t isc_result_t

View File

@ -89,7 +89,7 @@ keymgr_keyrole(dst_key_t* key)
return ("CSK"); return ("CSK");
} else if (ksk) { } else if (ksk) {
return ("KSK"); return ("KSK");
} else { } else if (zsk) {
return ("ZSK"); return ("ZSK");
} }
return ("NOSIGN"); return ("NOSIGN");

View File

@ -400,7 +400,7 @@ totext_ctx_init(const dns_master_style_t *style, const dns_indent_t *indentctx,
ctx->current_ttl = 0; ctx->current_ttl = 0;
ctx->current_ttl_valid = false; ctx->current_ttl_valid = false;
ctx->serve_stale_ttl = 0; ctx->serve_stale_ttl = 0;
ctx->indent = indentctx ? *indentctx : default_indent; ctx->indent = *indentctx;
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
@ -1547,12 +1547,13 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
cleanup: cleanup:
if (dctx->dbiter != NULL) if (dctx->dbiter != NULL) {
dns_dbiterator_destroy(&dctx->dbiter); dns_dbiterator_destroy(&dctx->dbiter);
if (dctx->db != NULL) }
if (dctx->db != NULL) {
dns_db_detach(&dctx->db); dns_db_detach(&dctx->db);
if (dctx != NULL) }
isc_mem_put(mctx, dctx, sizeof(*dctx)); isc_mem_put(mctx, dctx, sizeof(*dctx));
return (result); return (result);
} }

View File

@ -6368,8 +6368,7 @@ addnoqname(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
cleanup: cleanup:
dns_rdataset_disassociate(&neg); dns_rdataset_disassociate(&neg);
dns_rdataset_disassociate(&negsig); dns_rdataset_disassociate(&negsig);
if (noqname != NULL) free_noqname(mctx, &noqname);
free_noqname(mctx, &noqname);
return(result); return(result);
} }
@ -6413,8 +6412,7 @@ addclosest(dns_rbtdb_t *rbtdb, rdatasetheader_t *newheader,
cleanup: cleanup:
dns_rdataset_disassociate(&neg); dns_rdataset_disassociate(&neg);
dns_rdataset_disassociate(&negsig); dns_rdataset_disassociate(&negsig);
if (closest != NULL) free_noqname(mctx, &closest);
free_noqname(mctx, &closest);
return(result); return(result);
} }

View File

@ -13428,17 +13428,18 @@ ns_query(dns_zone_t *zone, dns_rdataset_t *soardataset, dns_stub_t *stub) {
cleanup: cleanup:
cancel_refresh(zone); cancel_refresh(zone);
if (stub != NULL) { stub->magic = 0;
stub->magic = 0; if (stub->version != NULL) {
if (stub->version != NULL) dns_db_closeversion(stub->db, &stub->version,
dns_db_closeversion(stub->db, &stub->version, false);
false);
if (stub->db != NULL)
dns_db_detach(&stub->db);
if (stub->zone != NULL)
zone_idetach(&stub->zone);
isc_mem_put(stub->mctx, stub, sizeof(*stub));
} }
if (stub->db != NULL) {
dns_db_detach(&stub->db);
}
if (stub->zone != NULL) {
zone_idetach(&stub->zone);
}
isc_mem_put(stub->mctx, stub, sizeof(*stub));
if (message != NULL) if (message != NULL)
dns_message_destroy(&message); dns_message_destroy(&message);
unlock: unlock:

View File

@ -321,17 +321,15 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
lcfg = isc_mem_get(lctx->mctx, sizeof(*lcfg)); lcfg = isc_mem_get(lctx->mctx, sizeof(*lcfg));
{ lcfg->lctx = lctx;
lcfg->lctx = lctx; lcfg->channellists = NULL;
lcfg->channellists = NULL; lcfg->channellist_count = 0;
lcfg->channellist_count = 0; lcfg->duplicate_interval = 0;
lcfg->duplicate_interval = 0; lcfg->highest_level = level;
lcfg->highest_level = level; lcfg->tag = NULL;
lcfg->tag = NULL; lcfg->dynamic = false;
lcfg->dynamic = false; ISC_LIST_INIT(lcfg->channels);
ISC_LIST_INIT(lcfg->channels); lcfg->magic = LCFG_MAGIC;
lcfg->magic = LCFG_MAGIC;
}
/* /*
* Create the default channels: * Create the default channels:
@ -377,18 +375,18 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) {
ISC_LOG_PRINTTIME); ISC_LOG_PRINTTIME);
} }
if (result == ISC_R_SUCCESS) if (result == ISC_R_SUCCESS) {
result = isc_log_createchannel(lcfg, "null", result = isc_log_createchannel(lcfg, "null",
ISC_LOG_TONULL, ISC_LOG_TONULL,
ISC_LOG_DYNAMIC, ISC_LOG_DYNAMIC,
NULL, 0); NULL, 0);
}
if (result == ISC_R_SUCCESS) if (result == ISC_R_SUCCESS) {
*lcfgp = lcfg; *lcfgp = lcfg;
} else {
else isc_logconfig_destroy(&lcfg);
if (lcfg != NULL) }
isc_logconfig_destroy(&lcfg);
return (result); return (result);
} }

View File

@ -956,8 +956,8 @@ isc__nmsocket_init(isc_nmsocket_t *sock, isc_nm_t *mgr,
} else { } else {
sock->statsindex = tcp6statsindex; sock->statsindex = tcp6statsindex;
} }
break;
isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]); isc__nm_incstats(sock->mgr, sock->statsindex[STATID_ACTIVE]);
break;
default: default:
break; break;
} }