From 395f6a1474255ba8c355bbcc326aae2ba7c3b566 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Tue, 2 Oct 2018 22:33:17 -0700 Subject: [PATCH] make update_log() work if zone is not set - update_log() is called to log update errors, but if those errors occur before the zone is set (for example, when returning NOTAUTH) it returns without logging anything. --- lib/ns/update.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/ns/update.c b/lib/ns/update.c index bdf6cc2dc9..d39eec7522 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -269,24 +269,34 @@ update_log(ns_client_t *client, dns_zone_t *zone, char namebuf[DNS_NAME_FORMATSIZE]; char classbuf[DNS_RDATACLASS_FORMATSIZE]; - if (client == NULL || zone == NULL) + if (client == NULL) { return; + } - if (isc_log_wouldlog(ns_lctx, level) == false) + if (isc_log_wouldlog(ns_lctx, level) == false) { return; - - dns_name_format(dns_zone_getorigin(zone), namebuf, - sizeof(namebuf)); - dns_rdataclass_format(dns_zone_getclass(zone), classbuf, - sizeof(classbuf)); + } va_start(ap, fmt); vsnprintf(message, sizeof(message), fmt, ap); va_end(ap); - ns_client_log(client, NS_LOGCATEGORY_UPDATE, NS_LOGMODULE_UPDATE, - level, "updating zone '%s/%s': %s", - namebuf, classbuf, message); + if (zone != NULL) { + dns_name_format(dns_zone_getorigin(zone), namebuf, + sizeof(namebuf)); + dns_rdataclass_format(dns_zone_getclass(zone), classbuf, + sizeof(classbuf)); + + ns_client_log(client, NS_LOGCATEGORY_UPDATE, + NS_LOGMODULE_UPDATE, + level, "updating zone '%s/%s': %s", + namebuf, classbuf, message); + } else { + ns_client_log(client, NS_LOGCATEGORY_UPDATE, + NS_LOGMODULE_UPDATE, + level, "%s", message); + } + } static void