Blame SOURCES/unbound-1.7.3-DNS-over-TLS-memory-leak.patch

b8c5d4
From 377d5b426a30fc915cf7905786f93c0ec89845b7 Mon Sep 17 00:00:00 2001
b8c5d4
From: Wouter Wijngaards <wouter@nlnetlabs.nl>
b8c5d4
Date: Tue, 25 Sep 2018 09:01:13 +0000
b8c5d4
Subject: [PATCH] - Add SSL cleanup for tcp timeout.
b8c5d4
b8c5d4
git-svn-id: file:///svn/unbound/trunk@4915 be551aaa-1e26-0410-a405-d3ace91eadb9
b8c5d4
---
b8c5d4
 services/outside_network.c | 11 +++++++++++
b8c5d4
 1 files changed, 9 insertions(+)
b8c5d4
diff --git a/services/outside_network.c b/services/outside_network.c
b8c5d4
index 5700ef8..b52cdab 100644
b8c5d4
--- a/services/outside_network.c
b8c5d4
+++ b/services/outside_network.c
b8c5d4
@@ -373,6 +373,8 @@ outnet_tcp_take_into_use(struct waiting_tcp* w, uint8_t* pkt, size_t pkt_len)
b8c5d4
                         if(!SSL_set1_host(pend->c->ssl, w->tls_auth_name)) {
b8c5d4
                                 log_err("SSL_set1_host failed");
b8c5d4
 				pend->c->fd = s;
b8c5d4
+				SSL_free(pend->c->ssl);
b8c5d4
+				pend->c->ssl = NULL;
b8c5d4
 				comm_point_close(pend->c);
b8c5d4
 				return 0;
b8c5d4
 			}
b8c5d4
@@ -1258,6 +1260,13 @@ outnet_tcptimer(void* arg)
b8c5d4
 	} else {
b8c5d4
 		/* it was in use */
b8c5d4
 		struct pending_tcp* pend=(struct pending_tcp*)w->next_waiting;
b8c5d4
+		if(pend->c->ssl) {
b8c5d4
+#ifdef HAVE_SSL
b8c5d4
+			SSL_shutdown(pend->c->ssl);
b8c5d4
+			SSL_free(pend->c->ssl);
b8c5d4
+			pend->c->ssl = NULL;
b8c5d4
+#endif
b8c5d4
+		}
b8c5d4
 		comm_point_close(pend->c);
b8c5d4
 		pend->query = NULL;
b8c5d4
 		pend->next_free = outnet->tcp_free;