From 87d3cb2f3348edf3753c487effd04e1af213f668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Sch=C3=A4fer?= Date: Sat, 2 Apr 2022 11:18:57 +0200 Subject: mod_tls: tell network backend to stop reading while preparing TLS --- plugins/mod_tls.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'plugins/mod_tls.lua') diff --git a/plugins/mod_tls.lua b/plugins/mod_tls.lua index 76964082..dcb2da21 100644 --- a/plugins/mod_tls.lua +++ b/plugins/mod_tls.lua @@ -129,6 +129,13 @@ end); module:hook("stanza/urn:ietf:params:xml:ns:xmpp-tls:starttls", function(event) local origin = event.origin; if can_do_tls(origin) then + if origin.conn.block_reads then + -- we need to ensure that no data is read anymore, otherwise we could end up in a situation where + -- is sent and the socket receives the TLS handshake (and passes the data to lua) before + -- it is asked to initiate TLS + -- (not with the classical single-threaded server backends) + origin.conn:block_reads() + end (origin.sends2s or origin.send)(starttls_proceed); if origin.destroyed then return end origin:reset_stream(); -- cgit v1.2.3