Use 'bname' in dns_catz_update_from_db() only when it is ready

There is a possible code path of using the uninitialized `bname`
character array while logging an error message.

Initialize the `bname` buffer earlier in the function.

Also, change the initialization routine to use a helper function.
This commit is contained in:
Aram Sargsyan
2022-03-17 14:47:15 +00:00
parent f57c51fe05
commit a5a6362e92

View File

@@ -1786,12 +1786,13 @@ dns_catz_update_from_db(dns_db_t *db, dns_catz_zones_t *catzs) {
dns_rdatasetiter_t *rdsiter = NULL;
dns_rdataset_t rdataset;
char bname[DNS_NAME_FORMATSIZE];
isc_buffer_t ibname;
uint32_t vers;
REQUIRE(DNS_DB_VALID(db));
REQUIRE(DNS_CATZ_ZONES_VALID(catzs));
dns_name_format(&db->origin, bname, DNS_NAME_FORMATSIZE);
/*
* Create a new catz in the same context as current catz.
*/
@@ -1805,10 +1806,6 @@ dns_catz_update_from_db(dns_db_t *db, dns_catz_zones_t *catzs) {
return;
}
isc_buffer_init(&ibname, bname, DNS_NAME_FORMATSIZE);
result = dns_name_totext(&db->origin, true, &ibname);
INSIST(result == ISC_R_SUCCESS);
result = dns_db_getsoaserial(db, oldzone->dbversion, &vers);
if (result != ISC_R_SUCCESS) {
/* A zone without SOA record?!? */