mirror of
https://github.com/FWGS/xash3d-fwgs.git
synced 2026-08-05 03:24:56 +08:00
engine: only allow net_sequence_window packets, prevent sudden, usually impossible, jumps
This commit is contained in:
@@ -155,7 +155,6 @@ void Mod_LoadCacheFile( const char *path, struct cache_user_s *cu );
|
||||
void *Mod_AliasExtradata( model_t *mod );
|
||||
void *Mod_StudioExtradata( model_t *mod );
|
||||
model_t *Mod_FindName( const char *name, qboolean trackCRC );
|
||||
model_t *Mod_LoadModel( model_t *mod, qboolean crash );
|
||||
model_t *Mod_ForName( const char *name, qboolean crash, qboolean trackCRC );
|
||||
qboolean Mod_ValidateCRC( const char *name, uint32_t crc );
|
||||
void Mod_NeedCRC( const char *name, qboolean needCRC );
|
||||
|
||||
@@ -292,7 +292,7 @@ Mod_LoadModel
|
||||
Loads a model into the cache
|
||||
==================
|
||||
*/
|
||||
model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
static model_t *Mod_LoadModel( model_t *mod, qboolean crash )
|
||||
{
|
||||
char tempname[MAX_QPATH];
|
||||
fs_offset_t length = 0;
|
||||
|
||||
@@ -94,6 +94,7 @@ CVAR_DEFINE_AUTO( net_showpackets, "0", FCVAR_PRIVILEGED, "show network packets"
|
||||
static CVAR_DEFINE_AUTO( net_chokeloop, "0", 0, "apply bandwidth choke to loopback packets" );
|
||||
static CVAR_DEFINE_AUTO( net_showdrop, "0", 0, "show packets that are dropped" );
|
||||
static CVAR_DEFINE_AUTO( net_qport, "0", FCVAR_READ_ONLY, "current quake netport" );
|
||||
static CVAR_DEFINE_AUTO( net_sequence_window, "256", 0, "reject sequenced packets that jump more than this many sequences ahead (anti-spoofing; 0 disables)" );
|
||||
CVAR_DEFINE_AUTO( net_send_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for outgoing messages" );
|
||||
CVAR_DEFINE_AUTO( net_recv_debug, "0", FCVAR_PRIVILEGED, "enable debugging output for incoming messages" );
|
||||
|
||||
@@ -173,6 +174,7 @@ void Netchan_Init( void )
|
||||
Cvar_RegisterVariable( &net_chokeloop );
|
||||
Cvar_RegisterVariable( &net_showdrop );
|
||||
Cvar_RegisterVariable( &net_qport );
|
||||
Cvar_RegisterVariable( &net_sequence_window );
|
||||
Cvar_RegisterVariable( &net_send_debug );
|
||||
Cvar_RegisterVariable( &net_recv_debug );
|
||||
Cvar_FullSet( net_qport.name, buf, net_qport.flags );
|
||||
@@ -1856,6 +1858,16 @@ qboolean Netchan_Process( netchan_t *chan, sizebuf_t *msg )
|
||||
return false;
|
||||
}
|
||||
|
||||
// reject packets that leap too far ahead of the expected sequence
|
||||
if( net_sequence_window.value > 0 && sequence > chan->incoming_sequence + (uint)net_sequence_window.value )
|
||||
{
|
||||
Con_Printf( S_WARN "%s: %s: sequence %u jumps %u ahead of expected %i (window %i), dropping\n",
|
||||
__func__, NET_AdrToString( chan->remote_address ),
|
||||
sequence, sequence - chan->incoming_sequence,
|
||||
chan->incoming_sequence, (int)net_sequence_window.value );
|
||||
return false;
|
||||
}
|
||||
|
||||
// dropped packets don't keep the message from being used
|
||||
net_drop = sequence - ( chan->incoming_sequence + 1 );
|
||||
if( net_drop > 0 && net_showdrop.value )
|
||||
|
||||
Reference in New Issue
Block a user