]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[v9_8] [rt36642] fix URI RR format
authorEvan Hunt <each@isc.org>
Thu, 31 Jul 2014 03:43:51 +0000 (20:43 -0700)
committerEvan Hunt <each@isc.org>
Thu, 31 Jul 2014 03:43:51 +0000 (20:43 -0700)
3906. [protocol] Update URI record format to comply with
draft-faltstrom-uri-08. [RT #36642]

(cherry picked from commit 7712d1660a308ec3de17f1ddbbf801eb0d663f3e)

CHANGES
lib/dns/rdata.c
lib/dns/rdata/generic/caa_257.c
lib/dns/rdata/generic/uri_256.c

diff --git a/CHANGES b/CHANGES
index c3ac17412b5f5a03583d3fb533554eb4bf1ab514..3409b0596b9ea0adbbb38e018824a73ae82ad618 100644 (file)
--- 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]
index bb8df665624318f8b419e0d27b8defe345f51b86..19d5dcae81c316e0ffb014a1643518cb8e3d2d36 100644 (file)
@@ -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)
index 835a23e6bcfce8fa71f329dc4bb982b47c1bd4ad..8ca43de28b2d7e68c4e00db35df48679cb059dd3 100644 (file)
@@ -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(&region, target, ISC_FALSE));
+       RETERR(multitxt_totext(&region, 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);
 }
index aef95947040a69e18280bd119c723808026d40dc..f8cb5ec4881a13928d95bf7103ed09dc448f3731 100644 (file)
@@ -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(&region, target, ISC_TRUE));
+       RETERR(multitxt_totext(&region, 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);
 }