]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
daemon/tls: fix a double-free for some cases of policy.TLS_FORWARD
authorOto Šťáva <oto.stava@nic.cz>
Thu, 23 Jun 2022 08:14:58 +0000 (10:14 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Wed, 29 Jun 2022 08:37:46 +0000 (10:37 +0200)
The double-free may have happened in some cases when the upstream
resolver was stopped while answering a forwarded query. I was reliably
reproducing it by running resperf on two kresd instances with one forwarded
to the other, and killing the upstream one.

NEWS
daemon/tls.c

diff --git a/NEWS b/NEWS
index de2f5b277d34427b4e86572a537a0a75c5916e9c..b0a3b467ae2f59591335a4ff2097cd661d232593 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,7 @@ Improvements
 Bugfixes
 --------
 - daemon/http: improved URI checks to fix some proxies (#746, !1311)
+- daemon/tls: fixed a double-free for some cases of policy.TLS_FORWARD (!1314)
 
 
 Knot Resolver 5.5.1 (2022-06-14)
index 44a28b5490a26a470cfa263ca854206858ebfa42..8d69d85675f9107b91fdec3e436f0892ef4d2dfa 100644 (file)
@@ -389,6 +389,8 @@ void tls_client_close(struct tls_client_ctx *ctx)
        /* Store the current session data for potential resumption of this session */
        if (ctx->params) {
                gnutls_free(ctx->params->session_data.data);
+               ctx->params->session_data.data = NULL;
+               ctx->params->session_data.size = 0;
                gnutls_session_get_data2(ctx->c.tls_session, &ctx->params->session_data);
        }