From: Aram Sargsyan Date: Thu, 12 Sep 2024 11:50:28 +0000 (+0000) Subject: Fix a 'serverquota' counter calculation bug X-Git-Tag: v9.21.2~38^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e430ce70390d181eb355c61f1f73c4c9d9943e06;p=thirdparty%2Fbind9.git Fix a 'serverquota' counter calculation bug The 'all_spilled' local variable in resolver.c:fctx_getaddresses() is 'true' by default, and only becomes false when there is at least one successfully found NS address. However, when a 'forward only;' configuration is used, the code jumps over the part where it looks for NS addresses and doesn't reset the 'all_spilled' to false, which results in incorretly increased 'serverquota' statistics variable, and also in invalid return error code from the function. The result code error didn't make any differences, because all codes other than 'ISC_R_SUCCESS' or 'DNS_R_WAIT' were treated in the same way, and the result code was never logged anywhere. Set the default value of 'all_spilled' to 'false', and only make it 'true' before actually starting to look up NS addresses. --- diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 6643bdc2338..f8d5cdc430d 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -3417,7 +3417,7 @@ fctx_getaddresses(fetchctx_t *fctx, bool badcache) { bool all_bad; dns_rdata_ns_t ns; bool need_alternate = false; - bool all_spilled = true; + bool all_spilled = false; unsigned int no_addresses = 0; unsigned int ns_processed = 0; @@ -3586,6 +3586,7 @@ normal_nses: } now = isc_stdtime_now(); + all_spilled = true; /* resets to false below after the first success */ INSIST(ISC_LIST_EMPTY(fctx->finds)); INSIST(ISC_LIST_EMPTY(fctx->altfinds));