]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Ensure ns_query_cancel() handles all recursions
authorMichał Kępień <michal@isc.org>
Tue, 14 Jun 2022 11:13:32 +0000 (13:13 +0200)
committerMichał Kępień <michal@isc.org>
Tue, 14 Jun 2022 11:13:32 +0000 (13:13 +0200)
Previously, multiple code paths reused client->query.fetch, so it was
enough for ns_query_cancel() to issue a single call to
dns_resolver_cancelfetch() with that fetch as an argument.  Now, since
each slot in the 'recursions' array can hold a reference to a separate
resolver fetch, ns_query_cancel() needs to handle all of them, so that
all recursion callbacks get a chance to clean up the associated
resources when a query is canceled.

lib/ns/query.c

index 17bfcd3ee7fd4bde1874516ec8bceb20ce11d9ea..0504bb021c0156e1c1c0f5a1e5ac230392398029 100644 (file)
@@ -660,9 +660,12 @@ ns_query_cancel(ns_client_t *client) {
        REQUIRE(NS_CLIENT_VALID(client));
 
        LOCK(&client->query.fetchlock);
-       if (FETCH_RECTYPE_NORMAL(client) != NULL) {
-               dns_resolver_cancelfetch(FETCH_RECTYPE_NORMAL(client));
-               FETCH_RECTYPE_NORMAL(client) = NULL;
+       for (int i = 0; i < RECTYPE_COUNT; i++) {
+               dns_fetch_t **fetchp = &client->query.recursions[i].fetch;
+               if (*fetchp != NULL) {
+                       dns_resolver_cancelfetch(*fetchp);
+                       *fetchp = NULL;
+               }
        }
        if (client->query.hookactx != NULL) {
                client->query.hookactx->cancel(client->query.hookactx);