From 2656eb1aebd518fe73e72da0471ee38b6fb613c9 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 26 Oct 2024 20:21:45 +0300 Subject: [PATCH] engine: fix A2S_GOLDSRC_INFO, it must always include Source Engine Query and a null terminator --- engine/client/cl_main.c | 2 +- engine/common/net_chan.c | 2 +- engine/common/netchan.h | 2 +- engine/common/protocol.h | 2 +- engine/server/sv_client.c | 2 +- engine/server/sv_query.c | 7 ++++--- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 06358687..d78bc09b 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1916,7 +1916,7 @@ static void CL_QueryServer_f( void ) switch( proto ) { case PROTO_GOLDSRC: - Netchan_OutOfBandPrint( NS_CLIENT, adr, "%cSource Engine Query", A2S_GOLDSRC_INFO ); + Netchan_OutOfBand( NS_CLIENT, adr, sizeof( A2S_GOLDSRC_INFO ), A2S_GOLDSRC_INFO ); // includes null terminator! break; case PROTO_LEGACY: Netchan_OutOfBandPrint( NS_CLIENT, adr, A2A_INFO" %i", PROTOCOL_LEGACY_VERSION ); diff --git a/engine/common/net_chan.c b/engine/common/net_chan.c index cbf26cbd..06788852 100644 --- a/engine/common/net_chan.c +++ b/engine/common/net_chan.c @@ -520,7 +520,7 @@ Netchan_OutOfBand Sends an out-of-band datagram ================ */ -void Netchan_OutOfBand( int net_socket, netadr_t adr, int len, byte *data ) +void Netchan_OutOfBand( int net_socket, netadr_t adr, int len, const byte *data ) { byte buf[MAX_PRINT_MSG + 4] = { 0xff, 0xff, 0xff, 0xff }; diff --git a/engine/common/netchan.h b/engine/common/netchan.h index 5912be3f..c95a8079 100644 --- a/engine/common/netchan.h +++ b/engine/common/netchan.h @@ -306,7 +306,7 @@ qboolean Netchan_CopyFileFragments( netchan_t *chan, sizebuf_t *msg ); void Netchan_CreateFragments( netchan_t *chan, sizebuf_t *msg ); int Netchan_CreateFileFragments( netchan_t *chan, const char *filename ); void Netchan_TransmitBits( netchan_t *chan, int lengthInBits, const byte *data ); -void Netchan_OutOfBand( int net_socket, netadr_t adr, int length, byte *data ); +void Netchan_OutOfBand( int net_socket, netadr_t adr, int length, const byte *data ); void Netchan_OutOfBandPrint( int net_socket, netadr_t adr, const char *format, ... ) _format( 3 ); qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg ); void Netchan_UpdateProgress( netchan_t *chan ); diff --git a/engine/common/protocol.h b/engine/common/protocol.h index c525d659..98e683a1 100644 --- a/engine/common/protocol.h +++ b/engine/common/protocol.h @@ -363,7 +363,7 @@ extern const char *const clc_strings[clc_lastmsg+1]; #define A2A_GOLDSRC_ACK "j" // no-op // from any to server -#define A2S_GOLDSRC_INFO 'T' +#define A2S_GOLDSRC_INFO "TSource Engine Query" #define A2S_GOLDSRC_RULES 'V' #define A2S_GOLDSRC_PLAYERS 'U' diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 6eeca401..4516c224 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -3176,7 +3176,7 @@ void SV_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) return; } - if( pcmd[0] == A2S_GOLDSRC_INFO || pcmd[0] == A2S_GOLDSRC_PLAYERS || pcmd[0] == A2S_GOLDSRC_RULES ) + if( !Q_strcmp( pcmd, A2S_GOLDSRC_INFO ) || pcmd[0] == A2S_GOLDSRC_PLAYERS || pcmd[0] == A2S_GOLDSRC_RULES ) { SV_SourceQuery_HandleConnnectionlessPacket( pcmd, from ); } diff --git a/engine/server/sv_query.c b/engine/server/sv_query.c index 636309d8..7f3a4048 100644 --- a/engine/server/sv_query.c +++ b/engine/server/sv_query.c @@ -173,11 +173,12 @@ SV_SourceQuery_HandleConnnectionlessPacket */ void SV_SourceQuery_HandleConnnectionlessPacket( const char *c, netadr_t from ) { - switch( c[0] ) + if( !Q_strcmp( c, A2S_GOLDSRC_INFO )) { - case A2S_GOLDSRC_INFO: SV_SourceQuery_Details( from ); - break; + } + else switch( c[0] ) + { case A2S_GOLDSRC_RULES: SV_SourceQuery_Rules( from ); break;