diff --git a/lib/dns/rcode.c b/lib/dns/rcode.c index 2ea6d1c886..fefc2c1c3d 100644 --- a/lib/dns/rcode.c +++ b/lib/dns/rcode.c @@ -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 #include @@ -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, ""); - array[size - 1] = '\0'; - } + if (result != ISC_R_SUCCESS) + strlcpy(array, "", size); } diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index 77c7f7bd24..0c76ad7237 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -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, ""); - array[size - 1] = '\0'; - } + if (result != ISC_R_SUCCESS) + strlcpy(array, "", size); } /*