mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 11:36:10 +00:00
LibGfx: Reject OS/2 BMP files with invalid bpp values
This commit is contained in:
parent
bd6d365166
commit
d6c0776b45
Notes:
sideshowbarker
2024-07-19 01:06:53 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/d6c0776b45b Pull-request: https://github.com/SerenityOS/serenity/pull/4294 Issue: https://github.com/SerenityOS/serenity/issues/4206
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();
|
||||
|
||||
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue