]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix error path issue in xfrin_xmlrender()
authorAram Sargsyan <aram@isc.org>
Mon, 25 Sep 2023 09:38:03 +0000 (09:38 +0000)
committerAram Sargsyan <aram@isc.org>
Wed, 27 Sep 2023 10:03:40 +0000 (10:03 +0000)
The TRY0 macro doesn't set the 'result' variable, so the error
log message is never printed. Remove the 'result' variable and
modify the function's control flow to be similar to the the
zone_xmlrender() function, with a separate error returning path.

bin/named/statschannel.c

index f44eddce7139869e1fdeb9e81a131b6da7ddbb1e..94c97da1e1cb9f80c008ed6a8a2dbdb1197f86bb 100644 (file)
@@ -1454,7 +1454,6 @@ cleanup:
 
 static isc_result_t
 xfrin_xmlrender(dns_zone_t *zone, void *arg) {
-       isc_result_t result;
        char buf[1024 + 32]; /* sufficiently large for zone name and class */
        dns_rdataclass_t rdclass;
        const char *ztype;
@@ -1479,23 +1478,30 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
                return (ISC_R_SUCCESS);
        }
 
-       result = dns_zone_getxfr(zone, &xfr, &is_running, &is_deferred,
-                                &is_presoa, &is_pending, &needs_refresh);
-       if (result != ISC_R_SUCCESS) {
-               result = ISC_R_SUCCESS;
-               goto cleanup;
+       if (dns_zone_getxfr(zone, &xfr, &is_running, &is_deferred, &is_presoa,
+                           &is_pending, &needs_refresh) != ISC_R_SUCCESS)
+       {
+               /*
+                * Failed to get information about the zone's incoming transfer
+                * (if any), but we still want to continue generating the
+                * remaining parts of the output.
+                */
+               return (ISC_R_SUCCESS);
        }
 
        if (!is_running && !is_deferred && !is_presoa && !is_pending &&
            !needs_refresh)
        {
+               if (xfr != NULL) {
+                       dns_xfrin_detach(&xfr);
+               }
                /* No ongoing/queued transfer. */
-               goto cleanup;
+               return (ISC_R_SUCCESS);
        }
 
        if (is_running && xfr == NULL) {
                /* The transfer is finished, and it's shutting down. */
-               goto cleanup;
+               return (ISC_R_SUCCESS);
        }
 
        TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "xfrin"));
@@ -1696,16 +1702,22 @@ xfrin_xmlrender(dns_zone_t *zone, void *arg) {
 
        TRY0(xmlTextWriterEndElement(writer)); /* xfrin */
 
-cleanup:
        if (xfr != NULL) {
                dns_xfrin_detach(&xfr);
        }
-       if (result != ISC_R_SUCCESS) {
-               isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
-                             NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
-                             "Failed at xfrin_xmlrender()");
+
+       return (ISC_R_SUCCESS);
+
+cleanup:
+       if (xfr != NULL) {
+               dns_xfrin_detach(&xfr);
        }
-       return (result);
+
+       isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
+                     NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
+                     "Failed at xfrin_xmlrender()");
+
+       return (ISC_R_FAILURE);
 }
 
 static isc_result_t