From f3bd27373d1d36e4cdebc87f89d130b3b0841bf7 Mon Sep 17 00:00:00 2001 From: Diego Fronza Date: Sat, 28 Nov 2020 18:07:29 -0300 Subject: [PATCH] Avoid iterating name twice when constructing fctx->info This is a minor performance improvement, we store the result of the first call to strlcat to use as an offset in the next call when constructing fctx->info string. (cherry picked from commit 49c40827f6b88b4c12751086aab529298587e265) --- lib/dns/resolver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 99c4486868..bf0eab36b7 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -4936,9 +4936,10 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type, isc_result_t iresult; isc_interval_t interval; unsigned int findoptions = 0; - char buf[DNS_NAME_FORMATSIZE + DNS_RDATATYPE_FORMATSIZE]; + char buf[DNS_NAME_FORMATSIZE + DNS_RDATATYPE_FORMATSIZE + 1]; char typebuf[DNS_RDATATYPE_FORMATSIZE]; isc_mem_t *mctx; + size_t p; /* * Caller must be holding the lock for bucket number 'bucketnum'. @@ -4965,8 +4966,8 @@ fctx_create(dns_resolver_t *res, const dns_name_t *name, dns_rdatatype_t type, */ dns_name_format(name, buf, sizeof(buf)); dns_rdatatype_format(type, typebuf, sizeof(typebuf)); - strlcat(buf, "/", sizeof(buf)); - strlcat(buf, typebuf, sizeof(buf)); + p = strlcat(buf, "/", sizeof(buf)); + strlcat(buf + p, typebuf, sizeof(buf)); fctx->info = isc_mem_strdup(mctx, buf); FCTXTRACE("create");