engine: workaround buggy stringop-overflow

This commit is contained in:
Alibek Omarov 2024-09-30 00:19:12 +03:00
parent 1357057bd8
commit 953ad98a16
3 changed files with 12 additions and 12 deletions

View file

@ -388,7 +388,6 @@ void CL_ParseStaticDecal( sizebuf_t *msg )
{ {
vec3_t origin; vec3_t origin;
int decalIndex, entityIndex, modelIndex; int decalIndex, entityIndex, modelIndex;
cl_entity_t *ent = NULL;
float scale; float scale;
int flags; int flags;
@ -1181,17 +1180,16 @@ CL_ParseBaseline
*/ */
void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy ) void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
{ {
int i, newnum; const entity_state_t nullstate = { 0 };
entity_state_t nullstate;
qboolean player;
cl_entity_t *ent;
Delta_InitClient (); // finalize client delta's Delta_InitClient (); // finalize client delta's
memset( &nullstate, 0, sizeof( nullstate ));
while( 1 ) while( 1 )
{ {
cl_entity_t *ent;
qboolean player;
int newnum;
if( legacy ) if( legacy )
{ {
newnum = MSG_ReadWord( msg ); newnum = MSG_ReadWord( msg );
@ -1207,10 +1205,10 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
Host_Error( "%s: no free edicts\n", __func__ ); Host_Error( "%s: no free edicts\n", __func__ );
ent = CL_EDICT_NUM( newnum ); ent = CL_EDICT_NUM( newnum );
memset( &ent->prevstate, 0, sizeof( ent->prevstate )); ent->prevstate = nullstate;
ent->index = newnum; ent->index = newnum;
MSG_ReadDeltaEntity( msg, &ent->prevstate, &ent->baseline, newnum, player, 1.0f ); MSG_ReadDeltaEntity( msg, &nullstate, &ent->baseline, newnum, player, 1.0f );
if( legacy ) if( legacy )
{ {
@ -1220,11 +1218,13 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy )
if( !legacy ) if( !legacy )
{ {
int i;
cl.instanced_baseline_count = MSG_ReadUBitLong( msg, 6 ); cl.instanced_baseline_count = MSG_ReadUBitLong( msg, 6 );
for( i = 0; i < cl.instanced_baseline_count; i++ ) for( i = 0; i < cl.instanced_baseline_count; i++ )
{ {
newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS ); int newnum = MSG_ReadUBitLong( msg, MAX_ENTITY_BITS );
MSG_ReadDeltaEntity( msg, &nullstate, &cl.instanced_baseline[i], newnum, false, 1.0f ); MSG_ReadDeltaEntity( msg, &nullstate, &cl.instanced_baseline[i], newnum, false, 1.0f );
} }
} }

View file

@ -1873,7 +1873,7 @@ If the delta removes the entity, entity_state_t->number will be set to MAX_EDICT
Can go from either a baseline or a previous packet_entity Can go from either a baseline or a previous packet_entity
================== ==================
*/ */
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase ) qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const entity_state_t *from, entity_state_t *to, int number, int delta_type, double timebase )
{ {
#if !XASH_DEDICATED #if !XASH_DEDICATED
delta_info_t *dt = NULL; delta_info_t *dt = NULL;

View file

@ -107,7 +107,7 @@ void MSG_ReadClientData( sizebuf_t *msg, struct clientdata_s *from, struct clien
void MSG_WriteWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase, int index ); void MSG_WriteWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase, int index );
void MSG_ReadWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase ); void MSG_ReadWeaponData( sizebuf_t *msg, struct weapon_data_s *from, struct weapon_data_s *to, double timebase );
void MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs ); void MSG_WriteDeltaEntity( struct entity_state_s *from, struct entity_state_s *to, sizebuf_t *msg, qboolean force, int type, double timebase, int ofs );
qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase ); qboolean MSG_ReadDeltaEntity( sizebuf_t *msg, const struct entity_state_s *from, struct entity_state_s *to, int num, int type, double timebase );
int Delta_TestBaseline( struct entity_state_s *from, struct entity_state_s *to, qboolean player, double timebase ); int Delta_TestBaseline( struct entity_state_s *from, struct entity_state_s *to, qboolean player, double timebase );
#endif//NET_ENCODE_H #endif//NET_ENCODE_H