2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-02-06 02:30:44 +03:00

Don't add an invalid decal into custom.hpk, otherwise clients may crash because they have no safe-checks WAD3 MIP-Header.

Related #755 (Only fixes server-side)
Fixes #757
This commit is contained in:
s1lent 2020-04-06 13:51:12 +07:00
parent 07539e225d
commit 7513e71d3b
3 changed files with 18 additions and 2 deletions

View File

@ -117,7 +117,9 @@ qboolean COM_CreateCustomization(customization_t *pListHead, resource_t *pResour
if ((pCust->resource.ucFlags & RES_CUSTOM) && pCust->resource.type == t_decal) if ((pCust->resource.ucFlags & RES_CUSTOM) && pCust->resource.type == t_decal)
{ {
pCust->resource.playernum = playernumber; pCust->resource.playernum = playernumber;
if (!CustomDecal_Validate(pCust->pBuffer, pResource->nDownloadSize))
if (!(flags & FCUST_VALIDATED) && // Don't validate twice
!CustomDecal_Validate(pCust->pBuffer, pResource->nDownloadSize))
{ {
bError = TRUE; bError = TRUE;
goto CustomizationError; goto CustomizationError;

View File

@ -3539,6 +3539,18 @@ void SV_ProcessFile(client_t *cl, char *filename)
return; return;
} }
int iCustomFlags = 0;
#ifdef REHLDS_FIXES
if (!CustomDecal_Validate(cl->netchan.tempbuffer, cl->netchan.tempbuffersize))
{
Con_Printf("Invalid custom decal from %s\n", cl->name);
return;
}
iCustomFlags |= FCUST_VALIDATED;
#endif
HPAK_AddLump(TRUE, "custom.hpk", resource, cl->netchan.tempbuffer, NULL); HPAK_AddLump(TRUE, "custom.hpk", resource, cl->netchan.tempbuffer, NULL);
resource->ucFlags &= ~RES_WASMISSING; resource->ucFlags &= ~RES_WASMISSING;
SV_MoveToOnHandList(resource); SV_MoveToOnHandList(resource);
@ -3552,7 +3564,8 @@ void SV_ProcessFile(client_t *cl, char *filename)
pList = pList->pNext; pList = pList->pNext;
} }
if (!COM_CreateCustomization(&cl->customdata, resource, -1, (FCUST_FROMHPAK | FCUST_WIPEDATA | RES_CUSTOM), NULL, NULL)) iCustomFlags |= (FCUST_FROMHPAK | FCUST_WIPEDATA | RES_CUSTOM);
if (!COM_CreateCustomization(&cl->customdata, resource, -1, iCustomFlags, NULL, NULL))
Con_Printf("Error parsing custom decal from %s\n", cl->name); Con_Printf("Error parsing custom decal from %s\n", cl->name);
} }

View File

@ -106,3 +106,4 @@ typedef struct customization_s
#define FCUST_FROMHPAK ( 1<<0 ) #define FCUST_FROMHPAK ( 1<<0 )
#define FCUST_WIPEDATA ( 1<<1 ) #define FCUST_WIPEDATA ( 1<<1 )
#define FCUST_IGNOREINIT ( 1<<2 ) #define FCUST_IGNOREINIT ( 1<<2 )
#define FCUST_VALIDATED ( 1<<3 )