From 247ed56e1790caa0a69f9f1027dfcb0d0fb5b8e8 Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Mon, 22 May 2017 16:44:50 +0100
Subject: [PATCH] Don't allow nonsense PT_ASKINFOVIAMS packets, nor any at all
 if offline

---
 src/d_clisrv.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/d_clisrv.c b/src/d_clisrv.c
index 87e51b4473..098430230b 100644
--- a/src/d_clisrv.c
+++ b/src/d_clisrv.c
@@ -3405,13 +3405,23 @@ static void HandlePacketFromAwayNode(SINT8 node)
 	switch (netbuffer->packettype)
 	{
 		case PT_ASKINFOVIAMS:
+			if (ms_RoomId < 0) // ignore if we're not actually on the MS right now
+			{
+				Net_CloseConnection(node); // and yes, close connection
+				break;
+			}
 			if (server && serverrunning)
 			{
 				INT32 clientnode = I_NetMakeNode(netbuffer->u.msaskinfo.clientaddr);
-				SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time));
-				SV_SendPlayerInfo(clientnode); // Send extra info
-				Net_CloseConnection(clientnode);
-				// Don't close connection to MS.
+				if (clientnode != -1)
+				{
+					SV_SendServerInfo(clientnode, (tic_t)LONG(netbuffer->u.msaskinfo.time));
+					SV_SendPlayerInfo(clientnode); // Send extra info
+					Net_CloseConnection(clientnode);
+					// Don't close connection to MS...
+				}
+				else
+					Net_CloseConnection(node); // ...unless the IP address is not valid
 			}
 			break;
 
-- 
GitLab