loader_tga: Abort file loading if the file obviously isn't large enough

Prevents an integer overflow later on that resulted in a datasize of
18446744073709551575 for id:000131,src:000104,op:havoc,rep:32,+cov
whose actual size is 48 byte.
This commit is contained in:
Fabian Keil 2014-12-04 12:49:04 +01:00 committed by Carsten Haitzler (Rasterman)
parent a104e317ce
commit a2cb5b9c9b
1 changed files with 8 additions and 0 deletions

View File

@ -237,6 +237,14 @@ load(ImlibImage * im, ImlibProgressFunction progress,
{
}
if ((size_t)ss.st_size < sizeof(tga_header) + header->idLength +
(footer_present ? sizeof(tga_footer) : 0))
{
munmap(seg, ss.st_size);
close(fd);
return 0;
}
/* skip over header */
filedata = (char *)filedata + sizeof(tga_header);