]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Ensure dig lookup is detached on UDP connect failure
authorEvan Hunt <each@isc.org>
Tue, 6 Apr 2021 23:49:14 +0000 (16:49 -0700)
committerOndřej Surý <ondrej@sury.org>
Wed, 7 Apr 2021 13:36:59 +0000 (15:36 +0200)
dig could hang when UDP connect failed due to a dangling lookup object.

bin/dig/dighost.c

index 3ec72f96f708d63d9d7326740a69a17a05250404..4d2aee207e03466f41f0d0e7306cc178c5656987 100644 (file)
@@ -1541,12 +1541,13 @@ _destroy_lookup(dig_lookup_t *lookup) {
        dig_server_t *s;
        void *ptr;
 
+       REQUIRE(lookup != NULL);
+       REQUIRE(ISC_LIST_EMPTY(lookup->q));
+
        debug("destroy_lookup");
 
        isc_refcount_destroy(&lookup->references);
 
-       REQUIRE(ISC_LIST_EMPTY(lookup->q));
-
        s = ISC_LIST_HEAD(lookup->my_server_list);
        while (s != NULL) {
                debug("freeing server %p belonging to %p", s, lookup);
@@ -2897,10 +2898,14 @@ udp_ready(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
                query_detach(&query);
                return;
        } else if (eresult != ISC_R_SUCCESS) {
+               dig_lookup_t *l = query->lookup;
+
                if (eresult != ISC_R_CANCELED) {
                        debug("udp setup failed: %s",
                              isc_result_totext(eresult));
                }
+
+               lookup_detach(&l);
                query_detach(&query);
                return;
        }