Browse Source

engine: imagelib: validate player decal image size (max 512x512)

pull/2/head
Alibek Omarov 2 years ago
parent
commit
21c898d796
  1. 2
      engine/common/imagelib/imagelib.h
  2. 11
      engine/common/imagelib/img_utils.c

2
engine/common/imagelib/imagelib.h

@ -103,6 +103,8 @@ typedef struct imglib_s
#define IMAGE_MAXHEIGHT 8192 #define IMAGE_MAXHEIGHT 8192
#define LUMP_MAXWIDTH 1024 // WorldCraft limits #define LUMP_MAXWIDTH 1024 // WorldCraft limits
#define LUMP_MAXHEIGHT 1024 #define LUMP_MAXHEIGHT 1024
#define PLDECAL_MAXWIDTH 512
#define PLDECAL_MAXHEIGHT 512
enum enum
{ {

11
engine/common/imagelib/img_utils.c

@ -237,7 +237,16 @@ void Image_AddCmdFlags( uint flags )
qboolean Image_ValidSize( const char *name ) qboolean Image_ValidSize( const char *name )
{ {
if( image.width > IMAGE_MAXWIDTH || image.height > IMAGE_MAXHEIGHT || image.width <= 0 || image.height <= 0 ) int max_width = IMAGE_MAXWIDTH;
int max_height = IMAGE_MAXHEIGHT;
if( Image_CheckFlag( IL_LOAD_PLAYER_DECAL ))
{
max_width = PLDECAL_MAXWIDTH;
max_height = PLDECAL_MAXHEIGHT;
}
if( image.width > max_width || image.height > max_height || image.width <= 0 || image.height <= 0 )
{ {
Con_DPrintf( S_ERROR "Image: (%s) dims out of range [%dx%d]\n", name, image.width, image.height ); Con_DPrintf( S_ERROR "Image: (%s) dims out of range [%dx%d]\n", name, image.width, image.height );
return false; return false;

Loading…
Cancel
Save