From: Colin Vidal Date: Sun, 5 Oct 2025 13:20:57 +0000 (+0200) Subject: synthrecord: fixing code nits X-Git-Tag: v9.21.15~77^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99724cf9e261f6a278cd79bc742aca873a900e40;p=thirdparty%2Fbind9.git synthrecord: fixing code nits Fixing an (invalid) Coverity NULL-dereference (ns_pluginctx_t is always defined) by enforcing a REQUIRE, and add a missing return value check. --- diff --git a/bin/plugins/synthrecord.c b/bin/plugins/synthrecord.c index 0f759816c9f..b5582bad498 100644 --- a/bin/plugins/synthrecord.c +++ b/bin/plugins/synthrecord.c @@ -70,6 +70,7 @@ synthrecord_reverseanswer(synthrecord_t *inst, isc_netaddr_t *na, isc_buffer_t addrb; char addrbdata[DNS_NAME_FORMATSIZE]; isc_region_t addrr; + isc_result_t result; REQUIRE(DNS_NAME_VALID(synthname)); REQUIRE(na->family == AF_INET || na->family == AF_INET6); @@ -78,7 +79,10 @@ synthrecord_reverseanswer(synthrecord_t *inst, isc_netaddr_t *na, isc_buffer_copyregion(&b, &inst->prefix); isc_buffer_init(&addrb, addrbdata, sizeof(addrbdata)); - isc_netaddr_totext(na, &addrb); + result = isc_netaddr_totext(na, &addrb); + if (result != ISC_R_SUCCESS) { + return result; + } /* * IDN compatibility, as an IPv6 begining or ending with `::` will be @@ -645,8 +649,8 @@ plugin_check(const char *parameters, const void *cfg, const char *cfgfile, const ns_pluginctx_t *ctx) { isc_result_t result; synthrecord_t *inst = NULL; - const dns_name_t *zname = (ctx == NULL) ? NULL : ctx->origin; + REQUIRE(ctx != NULL); if (ctx->source != NS_HOOKSOURCE_ZONE || ctx->origin == NULL) { isc_log_write(NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_HOOKS, ISC_LOG_INFO, @@ -660,7 +664,7 @@ plugin_check(const char *parameters, const void *cfg, const char *cfgfile, isc_mem_attach(mctx, &inst->mctx); result = synthrecord_parseconfig(inst, parameters, cfg, cfgfile, - cfgline, aclctx, zname); + cfgline, aclctx, ctx->origin); plugin_destroy((void **)&inst); return result;