LibGfx: Reject OS/2 BMP files with invalid bpp values

This commit is contained in:
Ben Wiederhake 2020-11-30 23:00:21 +01:00 committed by Andreas Kling
parent bd6d365166
commit d6c0776b45
Notes: sideshowbarker 2024-07-19 01:06:53 +09:00

View file

@ -543,7 +543,6 @@ static bool decode_bmp_core_dib(BMPLoadingContext& context, Streamer& streamer)
}
core.bpp = streamer.read_u16();
switch (core.bpp) {
case 1:
case 2:
@ -592,6 +591,19 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
}
core.bpp = streamer.read_u16();
switch (core.bpp) {
case 1:
case 2:
case 4:
case 8:
case 24:
break;
default:
// OS/2 didn't expect 16- or 32-bpp to be popular.
IF_BMP_DEBUG(dbg() << "BMP has an invalid bpp: " << core.bpp);
context.state = BMPLoadingContext::State::Error;
return false;
}
IF_BMP_DEBUG(dbg() << "BMP width: " << core.width);
IF_BMP_DEBUG(dbg() << "BMP height: " << core.height);