[iortcw] 24/89: All: Only allow connectionless print/echo from server/rcon address

Simon McVittie smcv at debian.org
Fri Sep 8 10:44:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to tag 1.51b
in repository iortcw.

commit c2bba260c4832a746966b9ca0e27012a662bc064
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Fri Jun 16 19:42:30 2017 -0400

    All: Only allow connectionless print/echo from server/rcon address
---
 MP/code/client/cl_main.c | 18 ++++++++++++++++++
 MP/code/client/client.h  |  2 ++
 SP/code/client/cl_main.c | 19 +++++++++++++------
 SP/code/client/client.h  |  2 ++
 4 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/MP/code/client/cl_main.c b/MP/code/client/cl_main.c
index d479de4..44511d1 100644
--- a/MP/code/client/cl_main.c
+++ b/MP/code/client/cl_main.c
@@ -1968,6 +1968,7 @@ void CL_Rcon_f( void ) {
 	}
 
 	NET_SendPacket( NS_CLIENT, strlen( message ) + 1, message, to );
+	cls.rconAddress = to;
 }
 
 /*
@@ -2939,7 +2940,14 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
 
 	// echo request from server
 	if ( !Q_stricmp( c, "echo" ) ) {
+#ifdef UPDATE_SERVER
 		NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv( 1 ) );
+#else
+		// NOTE: we may have to add exceptions for auth and update servers
+		if ( NET_CompareAdr( from, clc.serverAddress ) || NET_CompareAdr( from, cls.rconAddress ) ) {
+			NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) );
+		}
+#endif
 		return;
 	}
 
@@ -2957,10 +2965,20 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
 
 	// echo request from server
 	if ( !Q_stricmp( c, "print" ) ) {
+#ifdef UPDATE_SERVER
 		s = MSG_ReadString( msg );
 		
 		Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) );
 		Com_Printf( "%s", s );
+#else
+		// NOTE: we may have to add exceptions for auth and update servers
+		if ( NET_CompareAdr( from, clc.serverAddress ) || NET_CompareAdr( from, cls.rconAddress ) ) {
+			s = MSG_ReadString( msg );
+ 
+			Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) );
+			Com_Printf( "%s", s );
+		}
+#endif
 		return;
 	}
 
diff --git a/MP/code/client/client.h b/MP/code/client/client.h
index b8ef895..2634dc0 100644
--- a/MP/code/client/client.h
+++ b/MP/code/client/client.h
@@ -384,6 +384,8 @@ typedef struct {
 
 	netadr_t authorizeServer;
 
+	netadr_t rconAddress;
+
 	// DHM - Nerve :: Auto-update Info
 	char autoupdateServerNames[MAX_AUTOUPDATE_SERVERS][MAX_QPATH];
 	netadr_t autoupdateServer;
diff --git a/SP/code/client/cl_main.c b/SP/code/client/cl_main.c
index 93bd387..9558c85 100644
--- a/SP/code/client/cl_main.c
+++ b/SP/code/client/cl_main.c
@@ -1866,6 +1866,7 @@ void CL_Rcon_f( void ) {
 	}
 
 	NET_SendPacket( NS_CLIENT, strlen( message ) + 1, message, to );
+	cls.rconAddress = to;
 }
 
 /*
@@ -2739,7 +2740,10 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
 
 	// echo request from server
 	if ( !Q_stricmp( c, "echo" ) ) {
-		NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv( 1 ) );
+		// NOTE: we may have to add exceptions for auth and update servers
+		if ( NET_CompareAdr( from, clc.serverAddress ) || NET_CompareAdr( from, cls.rconAddress ) ) {
+			NET_OutOfBandPrint( NS_CLIENT, from, "%s", Cmd_Argv(1) );
+		}
 		return;
 	}
 
@@ -2756,11 +2760,14 @@ void CL_ConnectionlessPacket( netadr_t from, msg_t *msg ) {
 	}
 
 	// echo request from server
-	if ( !Q_stricmp( c, "print" ) ) {
-		s = MSG_ReadString( msg );
-		
-		Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) );
-		Com_Printf( "%s", s );
+	if ( !Q_stricmp(c, "print") ) {
+		// NOTE: we may have to add exceptions for auth and update servers
+		if ( NET_CompareAdr( from, clc.serverAddress ) || NET_CompareAdr( from, cls.rconAddress ) ) {
+			s = MSG_ReadString( msg );
+ 
+			Q_strncpyz( clc.serverMessage, s, sizeof( clc.serverMessage ) );
+			Com_Printf( "%s", s );
+		}
 		return;
 	}
 
diff --git a/SP/code/client/client.h b/SP/code/client/client.h
index e1528f1..e3463fc 100644
--- a/SP/code/client/client.h
+++ b/SP/code/client/client.h
@@ -370,6 +370,8 @@ typedef struct {
 
 	netadr_t authorizeServer;
 
+	netadr_t rconAddress;
+
 	// rendering info
 	glconfig_t glconfig;
 	qhandle_t charSetShader;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list