]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
check for size equal zero in _format(), replace snprintf of a fixed string with strlcpy
authorMark Andrews <marka@isc.org>
Tue, 16 Nov 2010 00:53:36 +0000 (00:53 +0000)
committerMark Andrews <marka@isc.org>
Tue, 16 Nov 2010 00:53:36 +0000 (00:53 +0000)
lib/dns/rcode.c
lib/dns/rdata.c

index 2ea6d1c8860cce6f1dbcbf23397849ea2347a315..fefc2c1c3d50f98cc83c38b1a8d8fd34a907a136 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rcode.c,v 1.12 2009/10/22 02:21:30 each Exp $ */
+/* $Id: rcode.c,v 1.13 2010/11/16 00:53:36 marka Exp $ */
 
 #include <config.h>
 #include <ctype.h>
@@ -493,6 +493,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);
        /*
@@ -504,8 +507,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);
 }
index 77c7f7bd2474ab63dbd89a76446824c2d01d0a9e..0c76ad723784eee558175e9df0f15a49a90515bc 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: rdata.c,v 1.204 2009/12/04 21:09:33 marka Exp $ */
+/* $Id: rdata.c,v 1.205 2010/11/16 00:53:36 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);
 }
 
 /*