From: Evan Hunt Date: Thu, 31 Jul 2014 03:43:51 +0000 (-0700) Subject: [v9_8] [rt36642] fix URI RR format X-Git-Tag: v9.8.8b2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee5e9d5193ee887fb14cc40d3ef51f5be2d266aa;p=thirdparty%2Fbind9.git [v9_8] [rt36642] fix URI RR format 3906. [protocol] Update URI record format to comply with draft-faltstrom-uri-08. [RT #36642] (cherry picked from commit 7712d1660a308ec3de17f1ddbbf801eb0d663f3e) --- diff --git a/CHANGES b/CHANGES index c3ac17412b5..3409b0596b9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3906. [protocol] Update URI record format to comply with + draft-faltstrom-uri-08. [RT #36642] + 3905. [bug] Address deadlock between view.c and adb.c. [RT #36341] 3904. [func] Add the RPZ SOA to the additional section. [RT36507] diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index bb8df665624..19d5dcae81c 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -123,16 +123,13 @@ static isc_result_t txt_fromwire(isc_buffer_t *source, isc_buffer_t *target); static isc_result_t -multitxt_totext(isc_region_t *source, isc_buffer_t *target, - isc_boolean_t lenbyte); +multitxt_totext(isc_region_t *source, isc_buffer_t *target); static isc_result_t -multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target, - isc_boolean_t lenbyte); +multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target); static isc_result_t -multitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target, - isc_boolean_t lenbyte); +multitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target); static isc_boolean_t name_prefix(dns_name_t *name, dns_name_t *origin, dns_name_t *target); @@ -1285,15 +1282,9 @@ txt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { /* * Conversion of TXT-like rdata fields without length limits. - * 'lenbyte' indicates whether to use length bytes in the encoding: - * The URI rdatatype uses length bytes for each 255-byte chunk of - * TXT, while the CAA rdatatype's length length is established by - * the overall rdata length. */ static isc_result_t -multitxt_totext(isc_region_t *source, isc_buffer_t *target, - isc_boolean_t lenbyte) -{ +multitxt_totext(isc_region_t *source, isc_buffer_t *target) { unsigned int tl; unsigned int n0, n; unsigned char *sp; @@ -1310,13 +1301,8 @@ multitxt_totext(isc_region_t *source, isc_buffer_t *target, *tp++ = '"'; tl--; do { - if (lenbyte) { - n0 = n = *sp++; - REQUIRE(n0 + 1 <= source->length); - } else { - n = source->length; - n0 = source->length - 1; - } + n = source->length; + n0 = source->length - 1; while (n--) { if (*sp < 0x20 || *sp >= 0x7f) { @@ -1353,9 +1339,7 @@ multitxt_totext(isc_region_t *source, isc_buffer_t *target, } static isc_result_t -multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target, - isc_boolean_t lenbyte) -{ +multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target) { isc_region_t tregion; isc_boolean_t escape; unsigned int n, nrem; @@ -1375,16 +1359,6 @@ multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target, if (nrem < 1) return (ISC_R_NOSPACE); - if (lenbyte) { - /* length byte */ - nrem--; - t++; - - /* 255 byte character-string slice */ - if (nrem > 255) - nrem = 255; - } - while (n != 0) { --n; c = (*s++) & 0xff; @@ -1419,19 +1393,13 @@ multitxt_fromtext(isc_textregion_t *source, isc_buffer_t *target, if (escape) return (DNS_R_SYNTAX); - if (lenbyte) { - *t0 = (unsigned char)(t - t0 - 1); - isc_buffer_add(target, *t0 + 1); - } else - isc_buffer_add(target, t - t0); + isc_buffer_add(target, t - t0); } while (n != 0); return (ISC_R_SUCCESS); } static isc_result_t -multitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target, - isc_boolean_t lenbyte) -{ +multitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target) { unsigned int n; isc_region_t sregion; isc_region_t tregion; @@ -1443,12 +1411,8 @@ multitxt_fromwire(isc_buffer_t *source, isc_buffer_t *target, do { if (n != 256U) return (DNS_R_SYNTAX); - if (lenbyte) { - n = *sregion.base + 1; - if (n > sregion.length) - return (ISC_R_UNEXPECTEDEND); - } else - n = sregion.length; + + n = sregion.length; isc_buffer_availableregion(target, &tregion); if (n > tregion.length) diff --git a/lib/dns/rdata/generic/caa_257.c b/lib/dns/rdata/generic/caa_257.c index 835a23e6bcf..8ca43de28b2 100644 --- a/lib/dns/rdata/generic/caa_257.c +++ b/lib/dns/rdata/generic/caa_257.c @@ -81,8 +81,7 @@ fromtext_caa(ARGS_FROMTEXT) { if (token.type != isc_tokentype_qstring && token.type != isc_tokentype_string) RETERR(DNS_R_SYNTAX); - RETERR(multitxt_fromtext(&token.value.as_textregion, target, - ISC_FALSE)); + RETERR(multitxt_fromtext(&token.value.as_textregion, target)); return (ISC_R_SUCCESS); } @@ -116,7 +115,7 @@ totext_caa(ARGS_TOTEXT) { /* * Value */ - RETERR(multitxt_totext(®ion, target, ISC_FALSE)); + RETERR(multitxt_totext(®ion, target)); return (ISC_R_SUCCESS); } @@ -164,7 +163,7 @@ fromwire_caa(ARGS_FROMWIRE) { /* * Value */ - RETERR(multitxt_fromwire(source, target, ISC_FALSE)); + RETERR(multitxt_fromwire(source, target)); return (ISC_R_SUCCESS); } diff --git a/lib/dns/rdata/generic/uri_256.c b/lib/dns/rdata/generic/uri_256.c index aef95947040..f8cb5ec4881 100644 --- a/lib/dns/rdata/generic/uri_256.c +++ b/lib/dns/rdata/generic/uri_256.c @@ -58,8 +58,7 @@ fromtext_uri(ARGS_FROMTEXT) { isc_tokentype_qstring, ISC_FALSE)); if (token.type != isc_tokentype_qstring) RETTOK(DNS_R_SYNTAX); - RETTOK(multitxt_fromtext(&token.value.as_textregion, target, - ISC_TRUE)); + RETTOK(multitxt_fromtext(&token.value.as_textregion, target)); return (ISC_R_SUCCESS); } @@ -95,7 +94,7 @@ totext_uri(ARGS_TOTEXT) { /* * Target URI */ - RETERR(multitxt_totext(®ion, target, ISC_TRUE)); + RETERR(multitxt_totext(®ion, target)); return (ISC_R_SUCCESS); } @@ -122,7 +121,7 @@ fromwire_uri(ARGS_FROMWIRE) { /* * Target URI */ - RETERR(multitxt_fromwire(source, target, ISC_TRUE)); + RETERR(multitxt_fromwire(source, target)); return (ISC_R_SUCCESS); }