]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3030. [bug] dns_rdatatype_format() handle a zero sized buffer.
authorMark Andrews <marka@isc.org>
Mon, 21 Feb 2011 06:43:23 +0000 (06:43 +0000)
committerMark Andrews <marka@isc.org>
Mon, 21 Feb 2011 06:43:23 +0000 (06:43 +0000)
                        [RT #22521]

CHANGES
lib/dns/rdata.c

diff --git a/CHANGES b/CHANGES
index aa3bf0d03b2290a0c864d4f1543026d24eb87332..5ae52166caebcdb4d2b7d1d7f90db2deb03290a6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3030.  [bug]           dns_rdatatype_format() handle a zero sized buffer.
+                       [RT #22521]
+
 3029.  [bug]           isc_netaddr_format() handle a zero sized buffer.
                        [RT #22521]
 
index f61d9e87cf27ad7d392bef40bb3e787bd79b48c0..64fc40e13ed0a0b0b06d52cd4d1356209332cb76 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rdata.c,v 1.209 2011/01/13 04:59:25 tbox Exp $ */
+/* $Id: rdata.c,v 1.209.8.1 2011/02/21 06:43:23 marka Exp $ */
 
 /*! \file */
 
@@ -963,6 +963,9 @@ dns_rdatatype_format(dns_rdatatype_t rdtype,
        isc_result_t result;
        isc_buffer_t buf;
 
+       if (size == 0U)
+               return;
+
        isc_buffer_init(&buf, array, size);
        result = dns_rdatatype_totext(rdtype, &buf);
        /*
@@ -974,10 +977,8 @@ dns_rdatatype_format(dns_rdatatype_t rdtype,
                else
                        result = ISC_R_NOSPACE;
        }
-       if (result != ISC_R_SUCCESS) {
-               snprintf(array, size, "<unknown>");
-               array[size - 1] = '\0';
-       }
+       if (result != ISC_R_SUCCESS)
+               strlcpy(array, "<unknown>", size);
 }
 
 /*