]> 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:50:42 +0000 (06:50 +0000)
committerMark Andrews <marka@isc.org>
Mon, 21 Feb 2011 06:50:42 +0000 (06:50 +0000)
                        [RT #22521]

CHANGES
lib/dns/rcode.c

diff --git a/CHANGES b/CHANGES
index e8455e47eb5b47c6e1fd081b00b487bdc1565f6a..dd831c7b43406e737cbdeebbf4bc0e847cc3ddb0 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..d8c07cb58911932493699eab613fd3add035070b 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.17 2011/02/21 06:50:42 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);
 }