2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

check for size equal zero in _format(), replace snprintf of a fixed string with strlcpy

This commit is contained in:
Mark Andrews
2010-11-16 00:53:36 +00:00
parent 432e1ce402
commit 7965c00ca8
2 changed files with 12 additions and 10 deletions

View 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);
}
/*