mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 14:07:59 +00:00
check for size equal zero in _format(), replace snprintf of a fixed string with strlcpy
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* 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 <config.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -493,6 +493,9 @@ dns_rdataclass_format(dns_rdataclass_t rdclass,
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_buffer_t buf;
|
isc_buffer_t buf;
|
||||||
|
|
||||||
|
if (size == 0U)
|
||||||
|
return;
|
||||||
|
|
||||||
isc_buffer_init(&buf, array, size);
|
isc_buffer_init(&buf, array, size);
|
||||||
result = dns_rdataclass_totext(rdclass, &buf);
|
result = dns_rdataclass_totext(rdclass, &buf);
|
||||||
/*
|
/*
|
||||||
@@ -504,8 +507,6 @@ dns_rdataclass_format(dns_rdataclass_t rdclass,
|
|||||||
else
|
else
|
||||||
result = ISC_R_NOSPACE;
|
result = ISC_R_NOSPACE;
|
||||||
}
|
}
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS)
|
||||||
snprintf(array, size, "<unknown>");
|
strlcpy(array, "<unknown>", size);
|
||||||
array[size - 1] = '\0';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* 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 */
|
/*! \file */
|
||||||
|
|
||||||
@@ -963,6 +963,9 @@ dns_rdatatype_format(dns_rdatatype_t rdtype,
|
|||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
isc_buffer_t buf;
|
isc_buffer_t buf;
|
||||||
|
|
||||||
|
if (size == 0U)
|
||||||
|
return;
|
||||||
|
|
||||||
isc_buffer_init(&buf, array, size);
|
isc_buffer_init(&buf, array, size);
|
||||||
result = dns_rdatatype_totext(rdtype, &buf);
|
result = dns_rdatatype_totext(rdtype, &buf);
|
||||||
/*
|
/*
|
||||||
@@ -974,10 +977,8 @@ dns_rdatatype_format(dns_rdatatype_t rdtype,
|
|||||||
else
|
else
|
||||||
result = ISC_R_NOSPACE;
|
result = ISC_R_NOSPACE;
|
||||||
}
|
}
|
||||||
if (result != ISC_R_SUCCESS) {
|
if (result != ISC_R_SUCCESS)
|
||||||
snprintf(array, size, "<unknown>");
|
strlcpy(array, "<unknown>", size);
|
||||||
array[size - 1] = '\0';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user