mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibGfx: Reject OS/2 BMP files with invalid bpp values
This commit is contained in:
parent
bd6d365166
commit
d6c0776b45
1 changed files with 13 additions and 1 deletions
|
@ -543,7 +543,6 @@ static bool decode_bmp_core_dib(BMPLoadingContext& context, Streamer& streamer)
|
||||||
}
|
}
|
||||||
|
|
||||||
core.bpp = streamer.read_u16();
|
core.bpp = streamer.read_u16();
|
||||||
|
|
||||||
switch (core.bpp) {
|
switch (core.bpp) {
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -592,6 +591,19 @@ static bool decode_bmp_osv2_dib(BMPLoadingContext& context, Streamer& streamer,
|
||||||
}
|
}
|
||||||
|
|
||||||
core.bpp = streamer.read_u16();
|
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 width: " << core.width);
|
||||||
IF_BMP_DEBUG(dbg() << "BMP height: " << core.height);
|
IF_BMP_DEBUG(dbg() << "BMP height: " << core.height);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue