handle larger targa dims, ketmar

This commit is contained in:
Adam D. Ruppe 2017-05-29 11:17:38 -04:00
parent 63b3eebe71
commit fce62fd863
2 changed files with 3 additions and 3 deletions

View File

@ -104,7 +104,7 @@ public ImageFileFormat guessImageFormatFromMemory (const(void)[] membuf) {
immutable ushort wImageHeight = cast(ushort)(buf.ptr[14]|(buf.ptr[15]<<8));
immutable ubyte bPixelDepth = buf.ptr[16];
immutable ubyte bImageDescriptor = buf.ptr[17];
if (wImageWidth < 1 || wImageHeight < 1 || wImageWidth > 16384 || wImageHeight > 16384) return false; // arbitrary limit
if (wImageWidth < 1 || wImageHeight < 1 || wImageWidth > 32000 || wImageHeight > 32000) return false; // arbitrary limit
immutable uint pixelsize = (bPixelDepth>>3);
switch (type) {
case 2: // truecolor, raw

View File

@ -229,8 +229,8 @@ private MemoryImage loadTgaImpl(ST) (auto ref ST fl, const(char)[] filename) {
fl.readStruct(hdr);
// parse header
// arbitrary size limits
if (hdr.width == 0 || hdr.width > 16384) throw new Exception("invalid tga width");
if (hdr.height == 0 || hdr.height > 16384) throw new Exception("invalid tga height");
if (hdr.width == 0 || hdr.width > 32000) throw new Exception("invalid tga width");
if (hdr.height == 0 || hdr.height > 32000) throw new Exception("invalid tga height");
switch (hdr.bpp) {
case 1: case 2: case 4: case 8: case 15: case 16: case 24: case 32: break;
default: throw new Exception("invalid tga bpp");