From 953ad98a16c8d78ab1d901e50464ebacc7dbc5a4 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 30 Sep 2024 00:19:12 +0300 Subject: [PATCH] engine: workaround buggy stringop-overflow --- engine/client/cl_parse.c | 20 ++++++++++---------- engine/common/net_encode.c | 2 +- engine/common/net_encode.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 4dfe07e9..7f8e497e 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -388,7 +388,6 @@ void CL_ParseStaticDecal( sizebuf_t *msg ) { vec3_t origin; int decalIndex, entityIndex, modelIndex; - cl_entity_t *ent = NULL; float scale; int flags; @@ -1181,17 +1180,16 @@ CL_ParseBaseline */ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy ) { - int i, newnum; - entity_state_t nullstate; - qboolean player; - cl_entity_t *ent; + const entity_state_t nullstate = { 0 }; Delta_InitClient (); // finalize client delta's - memset( &nullstate, 0, sizeof( nullstate )); - while( 1 ) { + cl_entity_t *ent; + qboolean player; + int newnum; + if( legacy ) { newnum = MSG_ReadWord( msg ); @@ -1207,10 +1205,10 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy ) Host_Error( "%s: no free edicts\n", __func__ ); ent = CL_EDICT_NUM( newnum ); - memset( &ent->prevstate, 0, sizeof( ent->prevstate )); + ent->prevstate = nullstate; 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 ) { @@ -1220,11 +1218,13 @@ void CL_ParseBaseline( sizebuf_t *msg, qboolean legacy ) if( !legacy ) { + int i; + cl.instanced_baseline_count = MSG_ReadUBitLong( msg, 6 ); 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 ); } } diff --git a/engine/common/net_encode.c b/engine/common/net_encode.c index 4459d870..4c8e7f4f 100644 --- a/engine/common/net_encode.c +++ b/engine/common/net_encode.c @@ -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 ================== */ -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 delta_info_t *dt = NULL; diff --git a/engine/common/net_encode.h b/engine/common/net_encode.h index 98e9d19e..fceaa52b 100644 --- a/engine/common/net_encode.h +++ b/engine/common/net_encode.h @@ -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_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 ); -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 ); #endif//NET_ENCODE_H