mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-23 10:39:16 +00:00
4128. [bug] Address issues raised by Coverity 7.6. [RT #39537]
This commit is contained in:
parent
52a487f71a
commit
e53e202ef3
2
CHANGES
2
CHANGES
@ -1,3 +1,5 @@
|
|||||||
|
4128. [bug] Address issues raised by Coverity 7.6. [RT #39537]
|
||||||
|
|
||||||
4127. [protocol] CDS and CDNSKEY need to be signed by the key signing
|
4127. [protocol] CDS and CDNSKEY need to be signed by the key signing
|
||||||
key as per RFC 7344, Section 4.1. [RT #37215]
|
key as per RFC 7344, Section 4.1. [RT #37215]
|
||||||
|
|
||||||
|
@ -3592,7 +3592,10 @@ main(int argc, char *argv[]) {
|
|||||||
* of keys rather early.
|
* of keys rather early.
|
||||||
*/
|
*/
|
||||||
ISC_LIST_INIT(keylist);
|
ISC_LIST_INIT(keylist);
|
||||||
isc_rwlock_init(&keylist_lock, 0, 0);
|
result = isc_rwlock_init(&keylist_lock, 0, 0);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
fatal("could not initialize keylist_lock: %s",
|
||||||
|
isc_result_totext(result));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill keylist with:
|
* Fill keylist with:
|
||||||
|
@ -471,7 +471,7 @@ ns_interface_listenudp(ns_interface_t *ifp) {
|
|||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
addtodispatch_failure:
|
addtodispatch_failure:
|
||||||
for (i = disp - 1; i <= 0; i--) {
|
for (i = disp - 1; i >= 0; i--) {
|
||||||
dns_dispatch_changeattributes(ifp->udpdispatch[i], 0,
|
dns_dispatch_changeattributes(ifp->udpdispatch[i], 0,
|
||||||
DNS_DISPATCHATTR_NOLISTEN);
|
DNS_DISPATCHATTR_NOLISTEN);
|
||||||
dns_dispatch_detach(&(ifp->udpdispatch[i]));
|
dns_dispatch_detach(&(ifp->udpdispatch[i]));
|
||||||
|
@ -297,6 +297,7 @@ rbt_init(char *filename, dns_rbt_t **rbt, isc_mem_t *mctx) {
|
|||||||
if ((rval != 0) || (dns_result != ISC_R_SUCCESS)) {
|
if ((rval != 0) || (dns_result != ISC_R_SUCCESS)) {
|
||||||
t_info("add of %s failed\n", p);
|
t_info("add of %s failed\n", p);
|
||||||
dns_rbt_destroy(rbt);
|
dns_rbt_destroy(rbt);
|
||||||
|
(void) free(p);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
@ -704,7 +705,7 @@ t9_walkchain(dns_rbtnodechain_t *chain, dns_rbt_t *rbt) {
|
|||||||
if (order >= 0) {
|
if (order >= 0) {
|
||||||
t_info("unexpected order %s %s %s\n",
|
t_info("unexpected order %s %s %s\n",
|
||||||
dnsname_totext(dns_fixedname_name(&fullname1)),
|
dnsname_totext(dns_fixedname_name(&fullname1)),
|
||||||
order == -1 ? "<" : (order == 0 ? "==" : ">"),
|
order == 0 ? "==" : ">",
|
||||||
dnsname_totext(dns_fixedname_name(&fullname2)));
|
dnsname_totext(dns_fixedname_name(&fullname2)));
|
||||||
++nprobs;
|
++nprobs;
|
||||||
}
|
}
|
||||||
|
@ -999,6 +999,12 @@ t_tasks4(void) {
|
|||||||
NULL, sizeof(*event));
|
NULL, sizeof(*event));
|
||||||
if (event == NULL) {
|
if (event == NULL) {
|
||||||
t_info("isc_event_allocate failed\n");
|
t_info("isc_event_allocate failed\n");
|
||||||
|
isc_result = isc_mutex_unlock(&T4_mx);
|
||||||
|
if (isc_result != ISC_R_SUCCESS) {
|
||||||
|
t_info("isc_mutex_unlock failed %s\n",
|
||||||
|
isc_result_totext(isc_result));
|
||||||
|
++T4_nprobs;
|
||||||
|
}
|
||||||
DESTROYLOCK(&T4_mx);
|
DESTROYLOCK(&T4_mx);
|
||||||
isc_task_destroy(&task);
|
isc_task_destroy(&task);
|
||||||
(void) isc_condition_destroy(&T4_cv);
|
(void) isc_condition_destroy(&T4_cv);
|
||||||
|
@ -240,8 +240,8 @@ dns_dlzcreate(isc_mem_t *mctx, const char *dlzname, const char *drivername,
|
|||||||
|
|
||||||
void
|
void
|
||||||
dns_dlzdestroy(dns_dlzdb_t **dbp) {
|
dns_dlzdestroy(dns_dlzdb_t **dbp) {
|
||||||
isc_mem_t *mctx;
|
|
||||||
dns_dlzdestroy_t destroy;
|
dns_dlzdestroy_t destroy;
|
||||||
|
dns_dlzdb_t *db;
|
||||||
|
|
||||||
/* Write debugging message to log */
|
/* Write debugging message to log */
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE,
|
||||||
@ -253,23 +253,19 @@ dns_dlzdestroy(dns_dlzdb_t **dbp) {
|
|||||||
*/
|
*/
|
||||||
REQUIRE(dbp != NULL && DNS_DLZ_VALID(*dbp));
|
REQUIRE(dbp != NULL && DNS_DLZ_VALID(*dbp));
|
||||||
|
|
||||||
if ((*dbp)->ssutable != NULL) {
|
db = *dbp;
|
||||||
dns_ssutable_detach(&(*dbp)->ssutable);
|
*dbp = NULL;
|
||||||
}
|
|
||||||
|
if (db->ssutable != NULL)
|
||||||
|
dns_ssutable_detach(&db->ssutable);
|
||||||
|
|
||||||
/* call the drivers destroy method */
|
/* call the drivers destroy method */
|
||||||
if ((*dbp) != NULL) {
|
if (db->dlzname != NULL)
|
||||||
mctx = (*dbp)->mctx;
|
isc_mem_free(db->mctx, db->dlzname);
|
||||||
if ((*dbp)->dlzname != NULL)
|
destroy = db->implementation->methods->destroy;
|
||||||
isc_mem_free(mctx, (*dbp)->dlzname);
|
(*destroy)(db->implementation->driverarg, db->dbdata);
|
||||||
destroy = (*dbp)->implementation->methods->destroy;
|
/* return memory and detach */
|
||||||
(*destroy)((*dbp)->implementation->driverarg,(*dbp)->dbdata);
|
isc_mem_putanddetach(&db->mctx, db, sizeof(dns_dlzdb_t));
|
||||||
/* return memory */
|
|
||||||
isc_mem_put(mctx, (*dbp), sizeof(dns_dlzdb_t));
|
|
||||||
isc_mem_detach(&mctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
*dbp = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*%
|
/*%
|
||||||
|
@ -1083,9 +1083,6 @@ comparekeys(const dst_key_t *key1, const dst_key_t *key2,
|
|||||||
if (key1 == key2)
|
if (key1 == key2)
|
||||||
return (ISC_TRUE);
|
return (ISC_TRUE);
|
||||||
|
|
||||||
if (key1 == NULL || key2 == NULL)
|
|
||||||
return (ISC_FALSE);
|
|
||||||
|
|
||||||
if (key1->key_alg != key2->key_alg)
|
if (key1->key_alg != key2->key_alg)
|
||||||
return (ISC_FALSE);
|
return (ISC_FALSE);
|
||||||
|
|
||||||
@ -1175,8 +1172,6 @@ dst_key_paramcompare(const dst_key_t *key1, const dst_key_t *key2) {
|
|||||||
|
|
||||||
if (key1 == key2)
|
if (key1 == key2)
|
||||||
return (ISC_TRUE);
|
return (ISC_TRUE);
|
||||||
if (key1 == NULL || key2 == NULL)
|
|
||||||
return (ISC_FALSE);
|
|
||||||
if (key1->key_alg == key2->key_alg &&
|
if (key1->key_alg == key2->key_alg &&
|
||||||
key1->func->paramcompare != NULL &&
|
key1->func->paramcompare != NULL &&
|
||||||
key1->func->paramcompare(key1, key2) == ISC_TRUE)
|
key1->func->paramcompare(key1, key2) == ISC_TRUE)
|
||||||
|
@ -2107,6 +2107,8 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, isc_uint32_t serial,
|
|||||||
char backup[1024];
|
char backup[1024];
|
||||||
isc_boolean_t is_backup = ISC_FALSE;
|
isc_boolean_t is_backup = ISC_FALSE;
|
||||||
|
|
||||||
|
REQUIRE(filename != NULL);
|
||||||
|
|
||||||
namelen = strlen(filename);
|
namelen = strlen(filename);
|
||||||
if (namelen > 4U && strcmp(filename + namelen - 4, ".jnl") == 0)
|
if (namelen > 4U && strcmp(filename + namelen - 4, ".jnl") == 0)
|
||||||
namelen -= 4;
|
namelen -= 4;
|
||||||
|
@ -292,7 +292,7 @@ loadctx_destroy(dns_loadctx_t *lctx);
|
|||||||
SETRESULT(lctx, result); \
|
SETRESULT(lctx, result); \
|
||||||
LOGIT(result); \
|
LOGIT(result); \
|
||||||
read_till_eol = ISC_TRUE; \
|
read_till_eol = ISC_TRUE; \
|
||||||
continue; \
|
break; \
|
||||||
} else if (result != ISC_R_SUCCESS) \
|
} else if (result != ISC_R_SUCCESS) \
|
||||||
goto log_and_cleanup; \
|
goto log_and_cleanup; \
|
||||||
} \
|
} \
|
||||||
|
@ -224,13 +224,13 @@ openssldh_generate(dst_key_t *key, int generator, void (*callback)(int)) {
|
|||||||
#else
|
#else
|
||||||
dh = DH_generate_parameters(key->key_size, generator,
|
dh = DH_generate_parameters(key->key_size, generator,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
|
if (dh == NULL)
|
||||||
|
return (dst__openssl_toresult2(
|
||||||
|
"DH_generate_parameters",
|
||||||
|
DST_R_OPENSSLFAILURE));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dh == NULL)
|
|
||||||
return (dst__openssl_toresult2("DH_generate_parameters",
|
|
||||||
DST_R_OPENSSLFAILURE));
|
|
||||||
|
|
||||||
if (DH_generate_key(dh) == 0) {
|
if (DH_generate_key(dh) == 0) {
|
||||||
DH_free(dh);
|
DH_free(dh);
|
||||||
return (dst__openssl_toresult2("DH_generate_key",
|
return (dst__openssl_toresult2("DH_generate_key",
|
||||||
|
@ -1382,12 +1382,20 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||||||
isc_result_t ret;
|
isc_result_t ret;
|
||||||
EVP_PKEY *pkey = NULL;
|
EVP_PKEY *pkey = NULL;
|
||||||
RSA *rsa = NULL, *pubrsa = NULL;
|
RSA *rsa = NULL, *pubrsa = NULL;
|
||||||
char *colon;
|
char *colon, *tmpengine = NULL;
|
||||||
|
|
||||||
UNUSED(pin);
|
UNUSED(pin);
|
||||||
|
|
||||||
if (engine == NULL)
|
if (engine == NULL) {
|
||||||
|
colon = strchr(label, ':');
|
||||||
|
if (colon == NULL)
|
||||||
DST_RET(DST_R_NOENGINE);
|
DST_RET(DST_R_NOENGINE);
|
||||||
|
tmpengine = isc_mem_strdup(key->mctx, label);
|
||||||
|
if (tmpengine == NULL)
|
||||||
|
DST_RET(ISC_R_NOMEMORY);
|
||||||
|
colon = strchr(tmpengine, ':');
|
||||||
|
*colon = '\0';
|
||||||
|
}
|
||||||
e = dst__openssl_getengine(engine);
|
e = dst__openssl_getengine(engine);
|
||||||
if (e == NULL)
|
if (e == NULL)
|
||||||
DST_RET(DST_R_NOENGINE);
|
DST_RET(DST_R_NOENGINE);
|
||||||
@ -1402,17 +1410,13 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||||||
if (pkey == NULL)
|
if (pkey == NULL)
|
||||||
DST_RET(dst__openssl_toresult2("ENGINE_load_private_key",
|
DST_RET(dst__openssl_toresult2("ENGINE_load_private_key",
|
||||||
ISC_R_NOTFOUND));
|
ISC_R_NOTFOUND));
|
||||||
if (engine != NULL) {
|
if (tmpengine != NULL) {
|
||||||
|
key->engine = tmpengine;
|
||||||
|
tmpengine = NULL;
|
||||||
|
} else {
|
||||||
key->engine = isc_mem_strdup(key->mctx, engine);
|
key->engine = isc_mem_strdup(key->mctx, engine);
|
||||||
if (key->engine == NULL)
|
if (key->engine == NULL)
|
||||||
DST_RET(ISC_R_NOMEMORY);
|
DST_RET(ISC_R_NOMEMORY);
|
||||||
} else {
|
|
||||||
key->engine = isc_mem_strdup(key->mctx, label);
|
|
||||||
if (key->engine == NULL)
|
|
||||||
DST_RET(ISC_R_NOMEMORY);
|
|
||||||
colon = strchr(key->engine, ':');
|
|
||||||
if (colon != NULL)
|
|
||||||
*colon = '\0';
|
|
||||||
}
|
}
|
||||||
key->label = isc_mem_strdup(key->mctx, label);
|
key->label = isc_mem_strdup(key->mctx, label);
|
||||||
if (key->label == NULL)
|
if (key->label == NULL)
|
||||||
@ -1437,6 +1441,8 @@ opensslrsa_fromlabel(dst_key_t *key, const char *engine, const char *label,
|
|||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
|
if (tmpengine != NULL)
|
||||||
|
isc_mem_free(key->mctx, tmpengine);
|
||||||
if (rsa != NULL)
|
if (rsa != NULL)
|
||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
if (pubrsa != NULL)
|
if (pubrsa != NULL)
|
||||||
|
@ -2353,7 +2353,6 @@ rotate_left(dns_rbtnode_t *node, dns_rbtnode_t **rootp) {
|
|||||||
PARENT(LEFT(child)) = node;
|
PARENT(LEFT(child)) = node;
|
||||||
LEFT(child) = node;
|
LEFT(child) = node;
|
||||||
|
|
||||||
if (child != NULL)
|
|
||||||
PARENT(child) = PARENT(node);
|
PARENT(child) = PARENT(node);
|
||||||
|
|
||||||
if (IS_ROOT(node)) {
|
if (IS_ROOT(node)) {
|
||||||
@ -2386,7 +2385,6 @@ rotate_right(dns_rbtnode_t *node, dns_rbtnode_t **rootp) {
|
|||||||
PARENT(RIGHT(child)) = node;
|
PARENT(RIGHT(child)) = node;
|
||||||
RIGHT(child) = node;
|
RIGHT(child) = node;
|
||||||
|
|
||||||
if (child != NULL)
|
|
||||||
PARENT(child) = PARENT(node);
|
PARENT(child) = PARENT(node);
|
||||||
|
|
||||||
if (IS_ROOT(node)) {
|
if (IS_ROOT(node)) {
|
||||||
|
@ -1161,22 +1161,17 @@ dns_rrl(dns_view_t *view,
|
|||||||
client_addr, now,
|
client_addr, now,
|
||||||
log_buf, log_buf_len);
|
log_buf, log_buf_len);
|
||||||
if (rrl_all_result != DNS_RRL_RESULT_OK) {
|
if (rrl_all_result != DNS_RRL_RESULT_OK) {
|
||||||
int level;
|
|
||||||
|
|
||||||
e = e_all;
|
e = e_all;
|
||||||
rrl_result = rrl_all_result;
|
rrl_result = rrl_all_result;
|
||||||
if (rrl_result == DNS_RRL_RESULT_OK)
|
if (isc_log_wouldlog(dns_lctx, DNS_RRL_LOG_DEBUG1)) {
|
||||||
level = DNS_RRL_LOG_DEBUG2;
|
|
||||||
else
|
|
||||||
level = DNS_RRL_LOG_DEBUG1;
|
|
||||||
if (isc_log_wouldlog(dns_lctx, level)) {
|
|
||||||
make_log_buf(rrl, e,
|
make_log_buf(rrl, e,
|
||||||
"prefer all-per-second limiting ",
|
"prefer all-per-second limiting ",
|
||||||
NULL, ISC_TRUE, qname, ISC_FALSE,
|
NULL, ISC_TRUE, qname, ISC_FALSE,
|
||||||
DNS_RRL_RESULT_OK, resp_result,
|
DNS_RRL_RESULT_OK, resp_result,
|
||||||
log_buf, log_buf_len);
|
log_buf, log_buf_len);
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL,
|
isc_log_write(dns_lctx, DNS_LOGCATEGORY_RRL,
|
||||||
DNS_LOGMODULE_REQUEST, level,
|
DNS_LOGMODULE_REQUEST,
|
||||||
|
DNS_RRL_LOG_DEBUG1,
|
||||||
"%s", log_buf);
|
"%s", log_buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1332,7 +1332,7 @@ dns_view_findzonecut2(dns_view_t *view, dns_name_t *name, dns_name_t *fname,
|
|||||||
if (result == ISC_R_SUCCESS) {
|
if (result == ISC_R_SUCCESS) {
|
||||||
if (zfname != NULL &&
|
if (zfname != NULL &&
|
||||||
(!dns_name_issubdomain(fname, zfname) ||
|
(!dns_name_issubdomain(fname, zfname) ||
|
||||||
(dns_zone_staticstub &&
|
(dns_zone_gettype(zone) == dns_zone_staticstub &&
|
||||||
dns_name_equal(fname, zfname)))) {
|
dns_name_equal(fname, zfname)))) {
|
||||||
/*
|
/*
|
||||||
* We found a zonecut in the cache, but our
|
* We found a zonecut in the cache, but our
|
||||||
|
@ -12782,10 +12782,10 @@ dns_zone_notifyreceive(dns_zone_t *zone, isc_sockaddr_t *from,
|
|||||||
dns_zone_log(zone, ISC_LOG_INFO, "notify from %s: no serial",
|
dns_zone_log(zone, ISC_LOG_INFO, "notify from %s: no serial",
|
||||||
fromtext);
|
fromtext);
|
||||||
zone->notifyfrom = *from;
|
zone->notifyfrom = *from;
|
||||||
local = zone->masteraddr;
|
remote = zone->masteraddr;
|
||||||
remote = zone->sourceaddr;
|
local = zone->sourceaddr;
|
||||||
UNLOCK_ZONE(zone);
|
UNLOCK_ZONE(zone);
|
||||||
dns_zonemgr_unreachabledel(zone->zmgr, &local, &remote);
|
dns_zonemgr_unreachabledel(zone->zmgr, &remote, &local);
|
||||||
dns_zone_refresh(zone);
|
dns_zone_refresh(zone);
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -723,7 +723,7 @@ isc__app_ctxrun(isc_appctx_t *ctx0) {
|
|||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
result = sigsuspend(&sset);
|
(void)sigsuspend(&sset);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* External, or BIND9 using multiple contexts:
|
* External, or BIND9 using multiple contexts:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user