summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx
diff options
context:
space:
mode:
authorBen Wiederhake <BenWiederhake.GitHub@gmx.de>2020-11-30 23:00:21 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-02 10:46:40 +0100
commitd6c0776b45bb9b26d96405d8d404431f861f51b9 (patch)
tree63d139283fc47778a8e139846128b86d2f19d178 /Libraries/LibGfx
parentbd6d36516636e63a273ac20857a2a31826ea3cac (diff)
downloadserenity-d6c0776b45bb9b26d96405d8d404431f861f51b9.zip
LibGfx: Reject OS/2 BMP files with invalid bpp values
Diffstat (limited to 'Libraries/LibGfx')
-rw-r--r--Libraries/LibGfx/BMPLoader.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/Libraries/LibGfx/BMPLoader.cpp b/Libraries/LibGfx/BMPLoader.cpp
index 84bada3d65..80cca5610d 100644
--- a/Libraries/LibGfx/BMPLoader.cpp
+++ b/Libraries/LibGfx/BMPLoader.cpp
@@ -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);