From: Mark Andrews Date: Mon, 1 May 2017 23:23:49 +0000 (+1000) Subject: 4612. [bug] Silence 'may be use uninitalised' warning and simplify X-Git-Tag: v9.12.0a1~322 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b09eb48f8af225414251c001b95b63d6c3e407dd;p=thirdparty%2Fbind9.git 4612. [bug] Silence 'may be use uninitalised' warning and simplify the code in lwres/getaddinfo:process_answer. [RT #45158] --- diff --git a/CHANGES b/CHANGES index acaf41e29c0..0196f3d5304 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +4612. [bug] Silence 'may be use uninitalised' warning and simplify + the code in lwres/getaddinfo:process_answer. + [RT #45158] + 4611. [bug] The default LMDB mapsize was too low and caused errors after few thousand zones were added using rndc addzone. A new config option "lmdb-mapsize" diff --git a/lib/irs/getaddrinfo.c b/lib/irs/getaddrinfo.c index c41be9fbe6c..b15830d20b5 100644 --- a/lib/irs/getaddrinfo.c +++ b/lib/irs/getaddrinfo.c @@ -681,6 +681,7 @@ process_answer(isc_task_t *task, isc_event_t *event) { dns_clientresevent_t *rev = (dns_clientresevent_t *)event; dns_rdatatype_t qtype; dns_name_t *name; + isc_boolean_t wantcname; REQUIRE(trans != NULL); resstate = trans->resstate; @@ -724,14 +725,26 @@ process_answer(isc_task_t *task, isc_event_t *event) { goto done; } + wantcname = ISC_TF((resstate->head->ai_flags & AI_CANONNAME) != 0); + /* Parse the response and construct the addrinfo chain */ for (name = ISC_LIST_HEAD(rev->answerlist); name != NULL; name = ISC_LIST_NEXT(name, link)) { isc_result_t result; dns_rdataset_t *rdataset; - isc_buffer_t b; - isc_region_t r; - char t[1024]; + char cname[1024]; + + if (wantcname) { + isc_buffer_t b; + + isc_buffer_init(&b, cname, sizeof(cname)); + result = dns_name_totext(name, ISC_TRUE, &b); + if (result != ISC_R_SUCCESS) { + error = EAI_FAIL; + goto done; + } + isc_buffer_putuint8(&b, '\0'); + } for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; @@ -741,17 +754,6 @@ process_answer(isc_task_t *task, isc_event_t *event) { if (rdataset->type != qtype) continue; - if ((resstate->head->ai_flags & AI_CANONNAME) != 0) { - isc_buffer_init(&b, t, sizeof(t)); - result = dns_name_totext(name, ISC_TRUE, &b); - if (result != ISC_R_SUCCESS) { - error = EAI_FAIL; - goto done; - } - isc_buffer_putuint8(&b, '\0'); - isc_buffer_usedregion(&b, &r); - } - for (result = dns_rdataset_first(rdataset); result == ISC_R_SUCCESS; result = dns_rdataset_next(rdataset)) { @@ -780,7 +782,8 @@ process_answer(isc_task_t *task, isc_event_t *event) { switch (family) { case AF_INET: dns_rdataset_current(rdataset, &rdata); - result = dns_rdata_tostruct(&rdata, &rdata_a, + result = dns_rdata_tostruct(&rdata, + &rdata_a, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); SIN(ai->ai_addr)->sin_port = @@ -791,7 +794,8 @@ process_answer(isc_task_t *task, isc_event_t *event) { break; case AF_INET6: dns_rdataset_current(rdataset, &rdata); - result = dns_rdata_tostruct(&rdata, &rdata_aaaa, + result = dns_rdata_tostruct(&rdata, + &rdata_aaaa, NULL); RUNTIME_CHECK(result == ISC_R_SUCCESS); SIN6(ai->ai_addr)->sin6_port = @@ -802,10 +806,8 @@ process_answer(isc_task_t *task, isc_event_t *event) { break; } - if ((resstate->head->ai_flags & AI_CANONNAME) - != 0) { - ai->ai_canonname = - strdup((const char *)r.base); + if (wantcname) { + ai->ai_canonname = strdup(cname); if (ai->ai_canonname == NULL) { error = EAI_MEMORY; goto done;