From: Michał Kępień Date: Tue, 8 Jan 2019 10:17:39 +0000 (+0100) Subject: Fix cleanup upon an error before TCP socket creation X-Git-Tag: v9.13.6~71^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13975b32c6a9ba50b249dede668a1461546b5793;p=thirdparty%2Fbind9.git Fix cleanup upon an error before TCP socket creation When a query times out after a socket is created and associated with a given dig_query_t structure, calling isc_socket_cancel() causes connect_done() to be run, which in turn takes care of all necessary cleanups. However, certain errors (e.g. get_address() returning ISC_R_FAMILYNOSUPPORT) may prevent a TCP socket from being created in the first place. Since force_timeout() may be used in code handling such errors, connect_timeout() needs to properly clean up a TCP query which is not associated with any socket. Call clear_query() from connect_timeout() after attempting to send a TCP query to the next available server if the timed out query does not have a socket associated with it, in order to prevent dig from hanging indefinitely due to the dig_query_t structure not being detached from its parent dig_lookup_t structure. --- diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 2f980ab4744..d4fddf0cac9 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2943,6 +2943,8 @@ connect_timeout(isc_task_t *task, isc_event_t *event) { if (query->sock != NULL) { isc_socket_cancel(query->sock, NULL, ISC_SOCKCANCEL_ALL); + } else { + clear_query(query); } } UNLOCK_LOOKUP;