2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 21:47:59 +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: 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);
}

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