Browse Source

engine: imagelib: fix integer overflow on huge images when calculating reflectivity

master
Alibek Omarov 5 months ago
parent
commit
dd2c369df3
  1. 2
      engine/common/imagelib/img_bmp.c
  2. 2
      engine/common/imagelib/img_tga.c
  3. 2
      engine/common/imagelib/img_wad.c

2
engine/common/imagelib/img_bmp.c

@ -28,7 +28,7 @@ qboolean Image_LoadBMP( const char *name, const byte *buffer, fs_offset_t filesi
rgba_t palette[256] = { 0 }; rgba_t palette[256] = { 0 };
int i, columns, column, rows, row, bpp = 1; int i, columns, column, rows, row, bpp = 1;
int cbPalBytes = 0, padSize = 0, bps = 0; int cbPalBytes = 0, padSize = 0, bps = 0;
int reflectivity[3] = { 0, 0, 0 }; uint reflectivity[3] = { 0, 0, 0 };
qboolean load_qfont = false; qboolean load_qfont = false;
bmp_t bhdr; bmp_t bhdr;
fs_offset_t estimatedSize; fs_offset_t estimatedSize;

2
engine/common/imagelib/img_tga.c

@ -29,7 +29,7 @@ qboolean Image_LoadTGA( const char *name, const byte *buffer, fs_offset_t filesi
rgba_t palette[256]; rgba_t palette[256];
byte red = 0, green = 0, blue = 0, alpha = 0; byte red = 0, green = 0, blue = 0, alpha = 0;
int readpixelcount, pixelcount; int readpixelcount, pixelcount;
int reflectivity[3] = { 0, 0, 0 }; uint reflectivity[3] = { 0, 0, 0 };
qboolean compressed; qboolean compressed;
tga_t targa_header; tga_t targa_header;

2
engine/common/imagelib/img_wad.c

@ -360,7 +360,7 @@ qboolean Image_LoadMIP( const char *name, const byte *buffer, fs_offset_t filesi
byte *fin, *pal; byte *fin, *pal;
int ofs[4], rendermode; int ofs[4], rendermode;
int i, pixels, numcolors; int i, pixels, numcolors;
int reflectivity[3] = { 0, 0, 0 }; uint reflectivity[3] = { 0, 0, 0 };
if( filesize < sizeof( mip )) if( filesize < sizeof( mip ))
return false; return false;

Loading…
Cancel
Save