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

CHANGES
lib/dns/rcode.c

diff --git a/CHANGES b/CHANGES
index 5ae52166caebcdb4d2b7d1d7f90db2deb03290a6..76d965911682ef5d41c150bf2a4da204fb455ed3 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3031.  [bug]           dns_rdataclass_format() handle a zero sized buffer.
+                       [RT #22521]
+
 3030.  [bug]           dns_rdatatype_format() handle a zero sized buffer.
                        [RT #22521]
 
index fd9d2fe0d3ccee625cfb22f1b9a4c7b49d0d6056..8e9c6f2cb96ba8ca9cf9210aaecadec27f2cd22a 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rcode.c,v 1.16 2010/12/23 04:07:58 marka Exp $ */
+/* $Id: rcode.c,v 1.16.14.1 2011/02/21 06:52:20 marka Exp $ */
 
 #include <config.h>
 #include <ctype.h>
@@ -494,6 +494,9 @@ dns_rdataclass_format(dns_rdataclass_t rdclass,
        isc_result_t result;
        isc_buffer_t buf;
 
+       if (size == 0U)
+               return;
+
        isc_buffer_init(&buf, array, size);
        result = dns_rdataclass_totext(rdclass, &buf);
        /*
@@ -505,8 +508,6 @@ dns_rdataclass_format(dns_rdataclass_t rdclass,
                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);
 }