]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3191. [bug] Print NULL records using unknown format. [RT #26392]
authorMark Andrews <marka@isc.org>
Wed, 2 Nov 2011 01:01:52 +0000 (01:01 +0000)
committerMark Andrews <marka@isc.org>
Wed, 2 Nov 2011 01:01:52 +0000 (01:01 +0000)
CHANGES
bin/tests/system/unknown/ns1/example-in.db
bin/tests/system/unknown/tests.sh
lib/dns/rdata.c
lib/dns/rdata/generic/null_10.c

diff --git a/CHANGES b/CHANGES
index 21c75e38af7e89cfdc71a9d43ea434db4bc2e056..28caea2592a2df4526229b67d8005d3d8e5e662d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+3191.  [bug]           Print NULL records using "unknown" format. [RT #26392]
+
 3190.  [bug]           Underflow in error handling in isc_mutexblock_init.
                        [RT #26397]
 
index 579bed868dd6bf703ef2b1fe0ee0fafc64aa1761..dc078f5f5f654a5573c4d0dd4f30623423712cbe 100644 (file)
@@ -13,7 +13,7 @@
 ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 ; PERFORMANCE OF THIS SOFTWARE.
 
-; $Id: example-in.db,v 1.7 2007/06/19 23:47:06 tbox Exp $
+; $Id: example-in.db,v 1.8 2011/11/02 01:01:52 marka Exp $
 
 $TTL 300       ; 5 minutes
 @                      SOA     mname1. . (
@@ -39,6 +39,9 @@ a10           IN      TYPE1   \# 4 0A000001
 a11            IN      TYPE1   \# 4 0a000001
 a12            IN      A       \# 4 0A000001
 
+null           IN      NULL    \# 1 00
+empty          IN      NULL    \# 0
+
 txt1           IN      TXT     "hello"
 txt2           CLASS1  TXT     "hello"
 txt3           IN      TYPE16  "hello"
index c234178e08bb393add1042aa3ae8153f8e68fb1e..62539e53643381542dfecdd30cd34ff8cf831f3a 100644 (file)
@@ -15,7 +15,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: tests.sh,v 1.10 2007/06/19 23:47:06 tbox Exp $
+# $Id: tests.sh,v 1.11 2011/11/02 01:01:52 marka Exp $
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
@@ -63,6 +63,20 @@ do
        status=`expr $status + $ret`
 done
 
+echo "I:querying for NULL record"
+ret=0
+$DIG +short $DIGOPTS null.example null in > dig.out || ret=1
+echo '\# 1 00' | diff - dig.out || ret=1
+[ $ret = 0 ] || echo "I: failed"
+status=`expr $status + $ret`
+
+echo "I:querying for empty NULL record"
+ret=0
+$DIG +short $DIGOPTS empty.example null in > dig.out || ret=1
+echo '\# 0' | diff - dig.out || ret=1
+[ $ret = 0 ] || echo "I: failed"
+status=`expr $status + $ret`
+
 echo "I:querying for various representations of a CLASS10 TYPE1 record"
 for i in 1 2
 do
index cfb7666b88f921e0e806dc55008f74ed9e09efa2..ac223bc0135b65f4fdb2935089112344dc16f259 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rdata.c,v 1.213 2011/03/11 06:11:24 marka Exp $ */
+/* $Id: rdata.c,v 1.214 2011/11/02 01:01:52 marka Exp $ */
 
 /*! \file */
 
@@ -217,6 +217,10 @@ warn_badmx(isc_token_t *token, isc_lex_t *lexer,
 static isc_uint16_t
 uint16_consume_fromregion(isc_region_t *region);
 
+static isc_result_t
+unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
+              isc_buffer_t *target);
+
 static inline int
 getquad(const void *src, struct in_addr *dst,
        isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks)
@@ -691,14 +695,54 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass,
        return (result);
 }
 
+static isc_result_t
+unknown_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
+              isc_buffer_t *target)
+{
+       isc_result_t result;
+       char buf[sizeof("65535")];
+       isc_region_t sr;
+
+       strlcpy(buf, "\\# ", sizeof(buf));
+       result = str_totext(buf, target);
+       if (result != ISC_R_SUCCESS)
+               return (result);
+
+       dns_rdata_toregion(rdata, &sr);
+       INSIST(sr.length < 65536);
+       snprintf(buf, sizeof(buf), "%u", sr.length);
+       result = str_totext(buf, target);
+       if (result != ISC_R_SUCCESS)
+               return (result);
+
+       if (sr.length != 0U) {
+               if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
+                       result = str_totext(" ( ", target);
+               else
+                       result = str_totext(" ", target);
+
+               if (result != ISC_R_SUCCESS)
+                       return (result);
+
+               if (tctx->width == 0) /* No splitting */
+                       result = isc_hex_totext(&sr, 0, "", target);
+               else
+                       result = isc_hex_totext(&sr, tctx->width - 2,
+                                               tctx->linebreak,
+                                               target);
+               if (result == ISC_R_SUCCESS &&
+                   (tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
+                       result = str_totext(" )", target);
+       }
+       return (result);
+}
+
 static isc_result_t
 rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
             isc_buffer_t *target)
 {
        isc_result_t result = ISC_R_NOTIMPLEMENTED;
        isc_boolean_t use_default = ISC_FALSE;
-       char buf[sizeof("65535")];
-       isc_region_t sr;
 
        REQUIRE(rdata != NULL);
        REQUIRE(tctx->origin == NULL ||
@@ -714,34 +758,8 @@ rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx,
 
        TOTEXTSWITCH
 
-       if (use_default) {
-               strlcpy(buf, "\\# ", sizeof(buf));
-               result = str_totext(buf, target);
-               INSIST(result == ISC_R_SUCCESS);
-               dns_rdata_toregion(rdata, &sr);
-               INSIST(sr.length < 65536);
-               snprintf(buf, sizeof(buf), "%u", sr.length);
-               result = str_totext(buf, target);
-               if (sr.length != 0 && result == ISC_R_SUCCESS) {
-                       if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
-                               result = str_totext(" ( ", target);
-                       else
-                               result = str_totext(" ", target);
-
-                       if (result != ISC_R_SUCCESS)
-                               return (result);
-
-                       if (tctx->width == 0) /* No splitting */
-                               result = isc_hex_totext(&sr, 0, "", target);
-                       else
-                               result = isc_hex_totext(&sr, tctx->width - 2,
-                                                       tctx->linebreak,
-                                                       target);
-                       if (result == ISC_R_SUCCESS &&
-                           (tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0)
-                               result = str_totext(" )", target);
-               }
-       }
+       if (use_default)
+               result = unknown_totext(rdata, tctx, target);
 
        return (result);
 }
index 717ed6533fbd112864d3aeff1f464a811d42cadc..73310e0f1bc18a910db0ceb35eace0245fd7ebf5 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: null_10.c,v 1.44 2009/12/04 22:06:37 tbox Exp $ */
+/* $Id: null_10.c,v 1.45 2011/11/02 01:01:52 marka Exp $ */
 
 /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */
 
@@ -43,11 +43,7 @@ static inline isc_result_t
 totext_null(ARGS_TOTEXT) {
        REQUIRE(rdata->type == 10);
 
-       UNUSED(rdata);
-       UNUSED(tctx);
-       UNUSED(target);
-
-       return (DNS_R_SYNTAX);
+       return (unknown_totext(rdata, tctx, target));
 }
 
 static inline isc_result_t