]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
address fctx reference count leaks; style
authorMark Andrews <marka@isc.org>
Wed, 15 Aug 2018 05:49:33 +0000 (15:49 +1000)
committerWitold Kręcicki <wpk@isc.org>
Tue, 23 Oct 2018 12:15:04 +0000 (12:15 +0000)
lib/dns/resolver.c

index 4af6b9e3760235253c54e4d3748dd91d7cf79a6c..39f2fd20e98411c80c47eb6b4fdb837061f3ece8 100644 (file)
@@ -3967,19 +3967,23 @@ fctx_try(fetchctx_t *fctx, bool retrying, bool badcache) {
         * We're minimizing and we're not yet at the final NS -
         * we need to launch a query for NS for 'upper' domain
         */
-       if (fctx->minimized == true) {
+       if (fctx->minimized) {
                unsigned int options = fctx->options;
                options &= ~DNS_FETCHOPT_QMINIMIZE;
                fctx_increference(fctx);
                task = res->buckets[bucketnum].task;
                result = dns_resolver_createfetch(fctx->res, &fctx->qminname,
                                                  fctx->qmintype, &fctx->domain,
-                                                 &fctx->nameservers, NULL, fctx->client,
-                                                 fctx->id, options, 0,
-                                                 fctx->qc, task, resume_qmin,
-                                                 fctx, &fctx->qminrrset,
-                                                 NULL, &fctx->qminfetch);
+                                                 &fctx->nameservers, NULL,
+                                                 fctx->client, fctx->id,
+                                                 options, 0, fctx->qc, task,
+                                                 resume_qmin, fctx,
+                                                 &fctx->qminrrset, NULL,
+                                                 &fctx->qminfetch);
                if (result != ISC_R_SUCCESS) {
+                       LOCK(&fctx->res->buckets[fctx->bucketnum].lock);
+                       bucket_empty = fctx_decreference(fctx);
+                       UNLOCK(&fctx->res->buckets[fctx->bucketnum].lock);
                        fctx_done(fctx, DNS_R_SERVFAIL, __LINE__);
                }
                return;
@@ -4103,8 +4107,10 @@ resume_qmin(isc_task_t *task, isc_event_t *event) {
        if (result == ISC_R_CANCELED) {
                fctx_done(fctx, result, __LINE__);
                goto cleanup;
-       } else if (NXDOMAIN_RESULT(result) || result == DNS_R_FORMERR ||
-                  result == DNS_R_REMOTEFORMERR)
+       }
+
+       if (NXDOMAIN_RESULT(result) || result == DNS_R_FORMERR ||
+           result == DNS_R_REMOTEFORMERR)
        {
                if ((fctx->options & DNS_FETCHOPT_QMIN_STRICT) == 0) {
                        isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER,
@@ -4118,7 +4124,6 @@ resume_qmin(isc_task_t *task, isc_event_t *event) {
                }
        }
 
-
        if (dns_rdataset_isassociated(&fctx->nameservers)) {
                dns_rdataset_disassociate(&fctx->nameservers);
        }
@@ -4132,7 +4137,7 @@ resume_qmin(isc_task_t *task, isc_event_t *event) {
 
        if (result != ISC_R_SUCCESS) {
                fctx_done(fctx, result, __LINE__);
-               return;
+               goto cleanup;
        }
        fcount_decr(fctx);
        dns_name_free(&fctx->domain, fctx->mctx);
@@ -4140,14 +4145,14 @@ resume_qmin(isc_task_t *task, isc_event_t *event) {
        result = dns_name_dup(fname, fctx->mctx, &fctx->domain);
        if (result != ISC_R_SUCCESS) {
                fctx_done(fctx, result, __LINE__);
-               return;
+               goto cleanup;
        }
        dns_name_free(&fctx->qmindcname, fctx->mctx);
        dns_name_init(&fctx->qmindcname, NULL);
        result = dns_name_dup(dcname, fctx->mctx, &fctx->qmindcname);
        if (result != ISC_R_SUCCESS) {
                fctx_done(fctx, result, __LINE__);
-               return;
+               goto cleanup;
        }
        fctx->ns_ttl = fctx->nameservers.ttl;
        fctx->ns_ttl_ok = true;
@@ -4404,6 +4409,9 @@ fctx_doshutdown(isc_task_t *task, isc_event_t *event) {
        if (fctx->nsfetch != NULL)
                dns_resolver_cancelfetch(fctx->nsfetch);
 
+       if (fctx->qminfetch != NULL)
+               dns_resolver_cancelfetch(fctx->qminfetch);
+
        /*
         * Shut down anything still running on behalf of this
         * fetch, and clean up finds and addresses.  To avoid deadlock