diff --git a/CHANGES b/CHANGES index d1522b072f..8b4d642693 100644 --- 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 diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 24c8bdf323..f6871aae21 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -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); } diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 89b53a309b..641daca25d 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -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);