BMP loader: Fix infinite loop with invalid bmp images (T6749)

https://phab.enlightenment.org/T6749
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773968
This commit is contained in:
Kim Woelders 2018-03-07 19:35:30 +01:00
parent 5a7644a0c0
commit 51a48ecfe9
1 changed files with 11 additions and 0 deletions

View File

@ -235,6 +235,17 @@ load(ImlibImage * im, ImlibProgressFunction progress,
ReadleLong(f, &rmask);
ReadleLong(f, &gmask);
ReadleLong(f, &bmask);
if (bitcount == 16)
{
rmask &= 0xffffU;
gmask &= 0xffffU;
bmask &= 0xffffU;
}
if (rmask == 0 || gmask == 0 || bmask == 0)
{
fclose(f);
return 0;
}
for (bit = bitcount - 1; bit >= 0; bit--)
{
if (bmask & (1 << bit))