]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use 'bname' in dns_catz_update_from_db() only when it is ready
authorAram Sargsyan <aram@isc.org>
Thu, 17 Mar 2022 14:47:15 +0000 (14:47 +0000)
committerAram Sargsyan <aram@isc.org>
Mon, 28 Mar 2022 10:17:56 +0000 (10:17 +0000)
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.

lib/dns/catz.c

index ca71a5d36a2e1e7d5e2aed68b28a4bd54769d687..b02157618a5fa94553751edc010ceccbadf5decf 100644 (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?!? */