Skip to content

Commit

Permalink
engine: client: fix possible svc_pings misparse by reading until null…
Browse files Browse the repository at this point in the history
… bit is encountered
  • Loading branch information
a1batross committed Dec 15, 2024
1 parent 3d30dc8 commit 48cc526
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions engine/client/cl_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,17 +1593,23 @@ collect pings and packet lossage from clients
*/
void CL_UpdateUserPings( sizebuf_t *msg )
{
int i, slot;
player_info_t *player;

for( i = 0; i < MAX_CLIENTS; i++ )
// a1ba: there was a MAX_PLAYERS check but it doesn't make sense
// because pings message always ends by null bit
while( 1 )
{
if( !MSG_ReadOneBit( msg )) break; // end of message
int slot;
player_info_t *player;

if( !MSG_ReadOneBit( msg ))
break; // end of message

slot = MSG_ReadUBitLong( msg, MAX_CLIENT_BITS );

if( slot >= MAX_CLIENTS )
if( unlikely( slot >= MAX_CLIENTS ))
{
Host_Error( "%s: svc_pings > MAX_CLIENTS\n", __func__ );
return;
}

player = &cl.players[slot];
player->ping = MSG_ReadUBitLong( msg, 12 );
Expand Down

0 comments on commit 48cc526

Please sign in to comment.