]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Use unknown format when totext() is not implemented for any RDATA (#40317)
authorMukund Sivaraman <muks@isc.org>
Tue, 18 Aug 2015 14:41:46 +0000 (20:11 +0530)
committerMukund Sivaraman <muks@isc.org>
Tue, 18 Aug 2015 14:43:55 +0000 (20:13 +0530)
(cherry picked from commit ec3dbae9eb0fdbda37c76c2b41e819c7982be1c4)

CHANGES
lib/dns/rdata.c
lib/dns/rdata/generic/loc_29.c

diff --git a/CHANGES b/CHANGES
index 7bb57968de1fc16f36a1fc7ce1f162e16a9185e2..44d8ba00e2e89f2326e4d8b4acda9127a0ddb330 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+4187.  [func]          When any RR type implementation doesn't
+                       implement totext() for the RDATA's wire
+                       representation and returns ISC_R_NOTIMPLEMENTED,
+                       such RDATA is now printed in unknown
+                       presentation format (RFC 3597). RR types affected
+                       include LOC(29) and APL(42). [RT #40317].
+
 4186.  [bug]           Fixed an RPZ bug where a QNAME would be matched
                        against a policy RR with wildcard owner name
                        (trigger) where the QNAME was the wildcard owner
index a59e44a2b8672f1300cecc873415573121c1e1a7..52453bd3b119dce9c61bb5ee6a8a8b22442b0b87 100644 (file)
@@ -837,6 +837,7 @@ rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
 {
        isc_result_t result = ISC_R_NOTIMPLEMENTED;
        isc_boolean_t use_default = ISC_FALSE;
+       unsigned int cur;
 
        REQUIRE(rdata != NULL);
        REQUIRE(tctx->origin == NULL ||
@@ -850,10 +851,17 @@ rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
                return (ISC_R_SUCCESS);
        }
 
+       cur = isc_buffer_usedlength(target);
+
        TOTEXTSWITCH
 
-       if (use_default)
+       if (use_default || (result == ISC_R_NOTIMPLEMENTED)) {
+               unsigned int u = isc_buffer_usedlength(target);
+
+               INSIST(u >= cur);
+               isc_buffer_subtract(target, u - cur);
                result = unknown_totext(rdata, tctx, target);
+       }
 
        return (result);
 }
index 89b53a309b31ae9610b19ca591c80567781ac7cd..641daca25d6849014c49af7d6524de1be0d09ca3 100644 (file)
@@ -480,7 +480,11 @@ totext_loc(ARGS_TOTEXT) {
 
        dns_rdata_toregion(rdata, &sr);
 
-       /* version = sr.base[0]; */
+       if (sr.base[0] != 0)
+               return (ISC_R_NOTIMPLEMENTED);
+
+       REQUIRE(rdata->length == 16);
+
        size = sr.base[1];
        INSIST((size&0x0f) < 10 && (size>>4) < 10);
        if ((size&0x0f)> 1)
@@ -573,8 +577,11 @@ fromwire_loc(ARGS_FROMWIRE) {
        isc_buffer_activeregion(source, &sr);
        if (sr.length < 1)
                return (ISC_R_UNEXPECTEDEND);
-       if (sr.base[0] != 0)
-               return (ISC_R_NOTIMPLEMENTED);
+       if (sr.base[0] != 0) {
+               /* Treat as unknown. */
+               isc_buffer_forward(source, sr.length);
+               return (mem_tobuffer(target, sr.base, sr.length));
+       }
        if (sr.length < 16)
                return (ISC_R_UNEXPECTEDEND);