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

more str{n}{cat,cpy} corrections rt45981_stage2

This commit is contained in:
Mark Andrews
2017-09-14 18:11:56 +10:00
parent bbe9f1dd95
commit cb629cdeda
26 changed files with 106 additions and 127 deletions

View File

@@ -252,8 +252,8 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source,
* isc_parse_uint32(). isc_parse_uint32() requires
* null termination, so we must make a copy.
*/
strncpy(buffer, source->base, sizeof(buffer));
buffer[sizeof(buffer) - 1] = '\0';
strlcpy(buffer, source->base,
ISC_MIN(source->length + 1, sizeof(buffer)));
INSIST(buffer[source->length] == '\0');
@@ -504,8 +504,12 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
char *endp;
unsigned int val;
strncpy(buf, source->base + 5, source->length - 5);
buf[source->length - 5] = '\0';
/*
* source->base is not required to be NUL terminated.
* Copy up to remaining bytes and NUL terminate.
*/
strlcpy(buf, source->base + 5,
ISC_MIN(source->length - 5 + 1, sizeof(buf)));
val = strtoul(buf, &endp, 10);
if (*endp == '\0' && val <= 0xffff) {
*classp = (dns_rdataclass_t)val;