about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2013-02-20 16:49:21 +0100
committeroy <Tom_Adams@web.de>2013-02-24 18:31:30 +0100
commit118d2ac837537cd625679a57aca03cd47f2e71a1 (patch)
treecb4d48b9e3e538dcfda857d5a1bbaaa079fffa8e /src
parent07c97822bba0f7b59c911aab2d6e85f84785b6ed (diff)
downloadzcatch-118d2ac837537cd625679a57aca03cd47f2e71a1.tar.gz
zcatch-118d2ac837537cd625679a57aca03cd47f2e71a1.zip
show reason for closing a connection within a debug message. Closes #1061
Diffstat (limited to 'src')
-rw-r--r--src/engine/shared/network_conn.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/engine/shared/network_conn.cpp b/src/engine/shared/network_conn.cpp
index 24c8f066..cd2df048 100644
--- a/src/engine/shared/network_conn.cpp
+++ b/src/engine/shared/network_conn.cpp
@@ -214,27 +214,25 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
 				m_State = NET_CONNSTATE_ERROR;
 				m_RemoteClosed = 1;
 
-				if(!m_BlockCloseMsg)
+				char Str[128] = {0};
+				if(pPacket->m_DataSize > 1)
 				{
-					if(pPacket->m_DataSize)
-					{
-						// make sure to sanitize the error string form the other party
-						char Str[128];
-						if(pPacket->m_DataSize < 128)
-							str_copy(Str, (char *)pPacket->m_aChunkData, pPacket->m_DataSize);
-						else
-							str_copy(Str, (char *)pPacket->m_aChunkData, sizeof(Str));
-						str_sanitize_strong(Str);
-
-						// set the error string
-						SetError(Str);
-					}
+					// make sure to sanitize the error string form the other party
+					if(pPacket->m_DataSize < 128)
+						str_copy(Str, (char *)&pPacket->m_aChunkData[1], pPacket->m_DataSize);
 					else
-						SetError("No reason given");
+						str_copy(Str, (char *)&pPacket->m_aChunkData[1], sizeof(Str));
+					str_sanitize_strong(Str);
+				}
+
+				if(!m_BlockCloseMsg)
+				{
+					// set the error string
+					SetError(Str);
 				}
 
 				if(g_Config.m_Debug)
-					dbg_msg("conn", "closed reason='%s'", ErrorString());
+					dbg_msg("conn", "closed reason='%s'", Str);
 			}
 			return 0;
 		}