mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-23 13:24:13 +00:00
engine: client: fix heap-buffer-overflow in remap when we switch model that have more remap textures than previous
This commit is contained in:
parent
8905883225
commit
36ff819daf
@ -41,11 +41,24 @@ CL_CmpStudioTextures
|
|||||||
return true if equal
|
return true if equal
|
||||||
====================
|
====================
|
||||||
*/
|
*/
|
||||||
qboolean CL_CmpStudioTextures( int numtexs, mstudiotexture_t *p1, mstudiotexture_t *p2 )
|
static qboolean CL_CmpStudioTextures( int numtexs, mstudiotexture_t *p1, remap_info_t *remap )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
mstudiotexture_t *p2;
|
||||||
|
|
||||||
if( !p1 || !p2 ) return false;
|
if( !p1 ) // no textures
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !remap ) // current model has no remap
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( !remap->textures ) // shouldn't happen, just in case
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( numtexs != remap->numtextures ) // amount of textures differs, it's a different model
|
||||||
|
return false;
|
||||||
|
|
||||||
|
p2 = remap->ptexture;
|
||||||
|
|
||||||
for( i = 0; i < numtexs; i++, p1++, p2++ )
|
for( i = 0; i < numtexs; i++, p1++, p2++ )
|
||||||
{
|
{
|
||||||
@ -282,10 +295,9 @@ void CL_AllocRemapInfo( cl_entity_t *entity, model_t *model, int topcolor, int b
|
|||||||
if( !phdr ) return; // bad model?
|
if( !phdr ) return; // bad model?
|
||||||
|
|
||||||
src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
|
src = (mstudiotexture_t *)(((byte *)phdr) + phdr->textureindex);
|
||||||
dst = (clgame.remap_info[i] ? clgame.remap_info[i]->ptexture : NULL);
|
|
||||||
|
|
||||||
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
|
// NOTE: we must copy all the structures 'mstudiotexture_t' for easy access when model is rendering
|
||||||
if( !CL_CmpStudioTextures( phdr->numtextures, src, dst ) || clgame.remap_info[i]->model != model )
|
if( !CL_CmpStudioTextures( phdr->numtextures, src, clgame.remap_info[i] ) || clgame.remap_info[i]->model != model )
|
||||||
{
|
{
|
||||||
// this code catches studiomodel change with another studiomodel with remap textures
|
// this code catches studiomodel change with another studiomodel with remap textures
|
||||||
// e.g. playermodel 'barney' with playermodel 'gordon'
|
// e.g. playermodel 'barney' with playermodel 'gordon'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user