mod_bosh: Abort early if request is missing hostname
authorKim Alvefur <zash@zash.se>
Sat, 02 Nov 2019 15:29:13 +0100
changeset 10381 4c36bc28b99e
parent 10380 b337df192a10
child 10382 04c4750ff8d2
mod_bosh: Abort early if request is missing hostname Prevents traceback from passing nil to nameprep()
plugins/mod_bosh.lua
--- a/plugins/mod_bosh.lua	Sat Nov 02 15:27:53 2019 +0100
+++ b/plugins/mod_bosh.lua	Sat Nov 02 15:29:13 2019 +0100
@@ -272,6 +272,15 @@
 		-- New session request
 		context.notopen = nil; -- Signals that we accept this opening tag
 
+		if not attr.to then
+			log("debug", "BOSH client tried to connect without specifying a host");
+			report_bad_host();
+			local close_reply = st.stanza("body", { xmlns = xmlns_bosh, type = "terminate",
+				["xmlns:stream"] = xmlns_streams, condition = "improper-addressing" });
+			response:send(tostring(close_reply));
+			return;
+		end
+
 		local to_host = nameprep(attr.to);
 		local wait = tonumber(attr.wait);
 		if not to_host then