commit 19d0e55: [Project] Rdns: Fix TCP stuff cleanup

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jan 5 11:28:16 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-01-03 20:55:54 +0000
URL: https://github.com/rspamd/rspamd/commit/19d0e55011f75fce39c8bb8c7d733043b8a0babd

[Project] Rdns: Fix TCP stuff cleanup

---
 contrib/librdns/resolver.c |  1 +
 contrib/librdns/util.c     | 15 +++++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/contrib/librdns/resolver.c b/contrib/librdns/resolver.c
index c5cebc572..a576135db 100644
--- a/contrib/librdns/resolver.c
+++ b/contrib/librdns/resolver.c
@@ -817,6 +817,7 @@ rdns_process_tcp_write (int fd, struct rdns_io_channel *ioc)
 			/* Packet has been fully written, remove it */
 			DL_DELETE(ioc->tcp->output_chain, oc);
 			/* Data in output buffer belongs to request */
+			REF_RELEASE(oc->req);
 			free (oc);
 			ioc->tcp->cur_output_chains --;
 		}
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index d96103bb7..b7cd99a67 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -665,6 +665,21 @@ rdns_ioc_tcp_reset (struct rdns_io_channel *ioc)
 		}
 
 		/* Clean all buffers and temporaries */
+		if (ioc->tcp->cur_read_buf) {
+			free (ioc->tcp->cur_read_buf);
+			ioc->tcp->read_buf_allocated = 0;
+			ioc->tcp->next_read_size = 0;
+			ioc->tcp->cur_read = 0;
+		}
+
+		struct rdns_tcp_output_chain *oc, *tmp;
+		DL_FOREACH_SAFE(ioc->tcp->output_chain, oc, tmp) {
+			REF_RELEASE(oc->req);
+			DL_DELETE (ioc->tcp->output_chain, oc);
+			free (oc);
+		}
+
+		ioc->tcp->cur_output_chains = 0;
 
 		ioc->flags &= ~RDNS_CHANNEL_CONNECTED;
 	}


More information about the Commits mailing list