Add checks for sane image sizes in some image loaders (bmp, jpg, tga, png)

Thanks @sfan5 for the original patch (got modified a bit): dbd39120e7
Forum: https://irrlicht.sourceforge.io/forum/viewtopic.php?f=2&t=52819&p=306518
Those are the common formats, but rest of image loaders should also call this some day.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6387 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2022-05-08 14:42:59 +00:00
parent 72b1522083
commit cfde879801
5 changed files with 23 additions and 3 deletions

View File

@ -313,6 +313,13 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
dim.Height = header.Height;
IImage* image = 0;
if ( !IImage::checkDataSizeLimit( (size_t)header.Width*header.Height*header.BPP) )
{
os::Printer::log("Image dimensions too large for file", file->getFileName(), ELL_WARNING);
goto cleanup;
}
switch(header.BPP)
{
case 1:
@ -348,7 +355,7 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
};
// clean up
cleanup:
delete [] paletteData;
delete [] bmpData;