]> 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:16:32 +0000 (01:16 +0000)
committerMark Andrews <marka@isc.org>
Wed, 2 Nov 2011 01:16:32 +0000 (01:16 +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 0e2d0093d86982f4203e243e26dd16b308006367..d00751045803746661acb71b9b44a1255c38bd7c 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..94023e701f481f934b26933754d7920d8726ec78 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.7.332.1 2011/11/02 01:16:32 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..5463a7cd2237a762eeabb0743d13348d622ecf94 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.10.332.1 2011/11/02 01:16:31 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 2b071bd4dec36de1f7b30e4a03b091f5b0cb64e5..d0306bc53645f13b0633bc3b4dd3404ff8443018 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rdata.c,v 1.199.50.6 2011/03/11 10:49:55 marka Exp $ */
+/* $Id: rdata.c,v 1.199.50.7 2011/11/02 01:16:26 marka Exp $ */
 
 /*! \file */
 
@@ -207,6 +207,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)
@@ -667,14 +671,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 ||
@@ -690,28 +734,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)
-                               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 00bb542962d9178654b51080e5ee23b99ae4a6ac..8f32608547863e16cc00ad619cd83972c8e505f4 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: null_10.c,v 1.42 2007/06/19 23:47:17 tbox Exp $ */
+/* $Id: null_10.c,v 1.42.332.1 2011/11/02 01:16:30 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