]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Fix resolution of unusual ip6.arpa names
authorDiego Fronza <diego@isc.org>
Wed, 26 Aug 2020 17:36:14 +0000 (14:36 -0300)
committerOndřej Surý <ondrej@isc.org>
Wed, 2 Sep 2020 14:52:39 +0000 (16:52 +0200)
Before this commit, BIND was unable to resolve ip6.arpa names like
the one reported in issue #1847 when using query minimization.

As reported in the issue, an attempt to resolve a name like
'rec-test-dom-158937817846788.test123.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.3.4.3.5.4.0.8.2.6.0.1.0.0.2.ip6.arpa'
using default settings would fail.

The reason was that query minimization algorithm in 'fctx_minimize_qname'
would divide any ip6.arpa names in increasing number of labels,
7,11, ... up to 35, thus limiting the destination name (minimized) to a number
of 35 labels.

In case the last query minimization attempt (with 35 labels) would fail with
NXDOMAIN, BIND would attempt the query mininimization again with the exact
same QNAME, limited on the 35 labels, and that in turn would fail again.

This fix avoids this fail loop by considering the extra labels that may appear
in the leftmost part of an ip6.arpa name, those after the IPv6 part.

(cherry picked from commit 230d79c1911c2520be24e08eb1b40366a2f6e05a)

lib/dns/resolver.c

index 8956baee8124f1337f82654adda4d12e0e9acaff..8a36693a9a4efe6734b4df95648cd57b31678fd7 100644 (file)
@@ -10658,8 +10658,10 @@ fctx_minimize_qname(fetchctx_t *fctx) {
                        fctx->qmin_labels = 17;
                } else if (fctx->qmin_labels < 19) {
                        fctx->qmin_labels = 19;
-               } else if (fctx->qmin_labels > 19) {
+               } else if (fctx->qmin_labels < 35) {
                        fctx->qmin_labels = 35;
+               } else {
+                       fctx->qmin_labels = nlabels;
                }
        } else if (fctx->qmin_labels > DNS_QMIN_MAXLABELS) {
                fctx->qmin_labels = DNS_MAX_LABELS + 1;