From 4c2dd50d64d13612e41a6f1d9f125e861a023e18 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 13 Sep 2017 21:19:11 -0700 Subject: [PATCH] [v9_11] clean up bufsize errors (cherry picked from commit 9b729a06b015165aacca2ed6f471eec41bef6ae1) --- lib/dns/name.c | 2 +- lib/dns/zone.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/dns/name.c b/lib/dns/name.c index 575eb20262..9ec52e3568 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -1648,7 +1648,7 @@ dns_name_tofilenametext(dns_name_t *name, isc_boolean_t omit_final_dot, trem--; nlen--; } else { - if (trem < 3) + if (trem < 4) return (ISC_R_NOSPACE); snprintf(tdata, trem, "%%%02X", c); tdata += 3; diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 9b232a187e..23d32ea140 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -1388,12 +1388,14 @@ dns_zone_getdbtype(dns_zone_t *zone, char ***argv, isc_mem_t *mctx) { size += strlen(zone->db_argv[i]) + 1; mem = isc_mem_allocate(mctx, size); if (mem != NULL) { + size_t remaining; tmp = mem; tmp2 = mem; tmp2 += (zone->db_argc + 1) * sizeof(char *); for (i = 0; i < zone->db_argc; i++) { + remaining = (size_t)(mem - tmp2); *tmp++ = tmp2; - strlcpy(tmp2, zone->db_argv[i], size); + strlcpy(tmp2, zone->db_argv[i], remaining); tmp2 += strlen(tmp2) + 1; } *tmp = NULL;