]> 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:47:44 +0000 (20:17 +0530)
(cherry picked from commit ec3dbae9eb0fdbda37c76c2b41e819c7982be1c4)
(cherry picked from commit ff82214714872a319a63cef87f664ee6806f2226)

Conflicts:
CHANGES

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

diff --git a/CHANGES b/CHANGES
index a657a29305570ddc58e5a95fa25dabd622f3dcc4..cad63ce723b716ceb4ec062b97ced7b7a16e10bb 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].
+
 4183.  [cleanup]       Use timing-safe memory comparisons in cryptographic
                        code. Also, the timing-safe comparison functions have
                        been renamed to avoid possible confusion with
index 7fcc5ebe49bb082226208f1c85d871d2a9f4972c..d9e2e5463675978788462c7532b21434d42f1d1f 100644 (file)
@@ -836,6 +836,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 ||
@@ -849,10 +850,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);